titu1994 / Neural-Style-Transfer

Keras Implementation of Neural Style Transfer from the paper "A Neural Algorithm of Artistic Style" (http://arxiv.org/abs/1508.06576) in Keras 2.0+
Apache License 2.0
2.26k stars 481 forks source link

ImportError: cannot import name 'imread' in google colab #57

Closed eulier1 closed 5 years ago

eulier1 commented 5 years ago

This is a marvelous labor, but unfortunately i'm unable to do actually run this command on google colab.

!python {dir_path}/{NETWORK} -h

It throw an error

Traceback (most recent call last):gf
  File "Neural-Style-Transfer/INetwork.py", line 5, in <module>
    from scipy.misc import imread, imresize, imsave, fromimage, toimage
ImportError: cannot import name 'imread'

But the name of the lib is right. https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.misc.imread.html

I'm kind of new in python. So idk what could it be :/

titu1994 commented 5 years ago

That's a really old script. Script deprecated imread and deferred it to skimage library. So the import needs to change. You can do it manually for now. I won't be able to change it soon as I'm travelling.

eulier1 commented 5 years ago

I did it but now i'm facing another challenge

W0622 16:25:34.197452 140701433337728 deprecation_wrapper.py:119] From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:517: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

titu1994 commented 5 years ago

It's a warning not an error. Let it continue running. It's because Keras 2.2.4 is still dependent on TF 1.12, where as the colab environment has shifted to 1.14.

As in all development, ignore warnings until they begin throwing errors. (joke)

eulier1 commented 5 years ago

all right, i have to replace

scipy.misc.imresize

with

from skimage.transform import resize

Now python are complaining with this.

File "Neural-Style-Transfer/INetwork.py", line 638, in <module> img = resize(img, (img_width, img_ht), interp=args.rescale_method) TypeError: resize() got an unexpected keyword argument 'interp'

:/ , is there any library that reduce the skin peeling sensation?.

titu1994 commented 5 years ago

Replace interp with mode

titu1994 commented 5 years ago

:/ , is there any library that reduce the skin peeling sensation?.

Sure you can use web solutions etc. No one is stopping you.