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

时间:2016-01-07 09:11:17

标签: python caffe pycaffe

当我在python中运行命令时:

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

它引发了一个错误:

  

ValueError:无法加载“bird.jpg”   请参阅文档:http://pillow.readthedocs.org/en/latest/installation.html#external-libraries

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

1 个答案:

答案 0 :(得分:1)

我解决了我的问题,以下是详细信息:

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

  

文件" /usr/local/lib/python2.7/dist-packages/scikit_image-0.11.3-py2.7-linux-x86_64.egg/skimage/io/_plugins/pil_plugin.py" ;,第52行,在imread   引发ValueError('无法加载"%s" \ n请参阅文档:%s'%(fname,site))   ValueError:无法加载" bird.jpg"   请参阅文档: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:读取图像文件时数据流损坏。

然后我跟着Matt W-D's solution重新安装jpeg6,删除Pillow安装的 PIL 包,并通过从http://effbot.org/downloads#pil下载文件重新安装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 

错误消失