0

when I run the command in python:

import caffe
img = caffe.io.load_image('bird.jpg')

it raised an error:

ValueError: Could not load "bird.jpg" Please see documentation at: http://pillow.readthedocs.org/en/latest/installation.html#external-libraries

I find some solutions at caffe users and Delbert's Blog, but they don't work, How can I fix it?

Fangxin
  • 781
  • 1
  • 7
  • 13
  • shouldn't is be [`caffe.io.load_image`](https://github.com/BVLC/caffe/blob/master/python/caffe/io.py#L278)? can you open `'bird.jpg'` in any external tool? is it possible the image file is corrupt? – Shai Jan 07 '16 at 13:57
  • Sorry about that, I got a mistake, it is **caffe.io.load_image** – Fangxin Jan 08 '16 at 01:16
  • how about the other questions I asked? is it possible that the image is corrupted? – Shai Jan 08 '16 at 06:53
  • can you load other images? – Shai Jan 08 '16 at 07:21
  • I can not load any images, I found solutions at webpages above, it mentioned, there is something wrong with Pillow, but I still can not solver this problem according to their solutions. – Fangxin Jan 08 '16 at 08:06

1 Answers1

1

I solved my problem, here is the details below:

First, I recheck this error imformation:

File "/usr/local/lib/python2.7/dist-packages/scikit_image-0.11.3-py2.7-linux-x86_64.egg/skimage/io/_plugins/pil_plugin.py", line 52, in imread raise ValueError('Could not load "%s"\nPlease see documentation at: %s' % (fname, site)) ValueError: Could not load "bird.jpg" Please see documentation at: http://pillow.readthedocs.org/en/latest/installation.html#external-libraries

it is a error with imread, I checked the file pil_plugin.py, I found it got thiss error when it came to

im = Image.open(fname)
try:
    # this will raise an IOError if the file is not readable
    im.getdata()[0]
except IOError:
    site = "http://pillow.readthedocs.org/en/latest/installation.html#external-libraries"
    raise ValueError('Could not load "%s"\nPlease see documentation at: %s' % (fname, site))
else:
    return pil_to_ndarray(im, dtype=dtype, img_num=img_num)

so it is most probably wrong with im.getdata(), then I run it and it raise an error:

im.getdata() IOError: broken data stream when reading image file.

then I followed Matt W-D's solution to reinstall jpeg6, delete the PIL package installed by Pillow, and reinstall PIL by downloading file from http://effbot.org/downloads#pil.

At last, I linked the libjpeg

ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
sudo ldconfigthe 

The error disappeared

Community
  • 1
  • 1
Fangxin
  • 781
  • 1
  • 7
  • 13