HIPS / autograd

Efficiently computes derivatives of NumPy code.
MIT License
6.96k stars 909 forks source link

example/fluidsim imageio issue #345

Open weymouth opened 6 years ago

weymouth commented 6 years ago

The scipy library for image reading is deprecated, with the functionality now in the imageio library. However, when I use this library the backward differentiation fails.

The only change made is to use imageio instead of scipy.misc in the line

from imageio import imread

which results in the error:

TypeError: Can't differentiate w.r.t. type <class 'imageio.core.util.Image'>

I suppose I could work around this by converting the image into a numpy array, but I wondered if you had a more native approach to working with images now.

weymouth commented 6 years ago

I just replicated the old scipy.misc.imread functionality with Pillow instead:

from PIL import Image
def imread(fname):
    return np.array(Image.open(fname))

This works well. I could send you a pull request if you want to keep the example up-to-date.

ericmjl commented 6 years ago

Totally would love to see the example updated! cc: @matjj @duvenaud