caffe.io.load_image() 错误,无法加载图像

error in caffe.io.load_image(), it cannot load image

当我运行 python中的命令时:

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

它引发了一个错误:

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

我在 caffe users and Delbert's Blog 找到了一些解决方案,但它们不起作用,我该如何解决?

我的问题解决了,详情如下:

首先,我重新检查了这个错误信息:

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

这是 imread 的错误,我检查了文件 pil_plugin.py,我发现它在执行时出现了这个错误来到

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)

所以 im.getdata() 很可能是错误的,然后我 运行 它引发了一个错误:

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

然后我关注了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

最后,我链接了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 

错误消失