neural_artistic_style icon indicating copy to clipboard operation
neural_artistic_style copied to clipboard

Unkonw exception in imread(path) from neural_artistic_style.py

Open Whiteha opened this issue 9 years ago • 5 comments

I got this fault:

/usr/lib/python2.7/dist-packages/pkg_resources/init.py:1224: UserWarning: /home/anonym/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable). warnings.warn(msg, UserWarning) CUDArray: CUDA back-end not available, using NumPy. Traceback (most recent call last): File "neural_artistic_style.py", line 120, in run() File "neural_artistic_style.py", line 89, in run style_img = imread(args.style) File "neural_artistic_style.py", line 40, in imread return scipy.misc.imread(path).astype(dp.float_) TypeError: float() argument must be a string or a number

Have any ideas?

Whiteha avatar Sep 04 '15 14:09 Whiteha

Strange, make sure scipy.misc.imread(path) returns a NumPy array.

andersbll avatar Sep 04 '15 14:09 andersbll

That's right? (screen from my attempt to find out the cause) screenshot from 2015-09-04 17 30 39

Whiteha avatar Sep 04 '15 14:09 Whiteha

Hm, it seems to me that scipy.misc.imread() is returning a PIL object. If this is the case, you need fix your scipy installation such that it can read your images. Try to look it up on the web.

andersbll avatar Sep 04 '15 14:09 andersbll

I saw this same error, and was able to fix it by doing the following (not sure which are responsible, since I did them all at once):

  • install scikit-image and matplotlib; the latter may have unmet dependencies -uninstall any scipy version, and install again with sudo pip install pip install git+https://github.com/scipy/scipy.git
  • uninstall Pillow
  • install all of the external libraries listed here required by Pillow: http://pillow.readthedocs.org/en/latest/installation.html#external-libraries (my guess is that installing one/some of these is what made the difference)
  • reinstall Pillow

rmurray2 avatar Sep 10 '15 12:09 rmurray2

@rmurray2: Thank you for the insight! Another possibility is to use the Anaconda Python distribution. It usually provides working versions of Pillow/Scipy. :)

andersbll avatar Sep 10 '15 18:09 andersbll