Classifying ImageNet - error in -- input_image = caffe.io.load_image(IMAGE_FILE)

559 views
Skip to first unread message

Ofer Zilberstein

unread,
Apr 17, 2015, 8:04:47 AM4/17/15
to caffe...@googlegroups.com

Hi,

I'm trying to run the Imagenet example and I get error in reading the image :

 input_image = caffe.io.load_image(IMAGE_FILE)
  File "/usr/lib/python2.7/site-packages/caffe/io.py", line 288, in load_image
    img = skimage.img_as_float(skimage.io.imread(filename)).astype(np.float32)
  File "/usr/lib64/python2.7/site-packages/skimage/io/_io.py", line 100, in imread
    img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
  File "/usr/lib64/python2.7/site-packages/skimage/io/manage_plugins.py", line 207, in call_plugin
    return func(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/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 "images/cat_gray.jpg"

Any ideas ?

Matt Hill

unread,
Apr 30, 2015, 3:32:36 PM4/30/15
to caffe...@googlegroups.com
  It seems that libjpeg-devel has to be there before pillow is installed for it to work.  So, after installing libjpeg-devel, try re-installing pillow , like "pip install -I pillow"

Matt

Dong Zhen

unread,
Oct 27, 2015, 9:54:56 AM10/27/15
to Caffe Users
Hi, do you fix this problem? I'm facing the same problem. Besides, the "caffe.io.load_image" function is able to be conducted successfully in the python terminal, but it will report errors when writing in cpp files.
Any ideas? Thank you.

在 2015年4月17日星期五 UTC+8下午8:04:47,Ofer Zilberstein写道:

Matt Hill

unread,
Oct 27, 2015, 12:21:20 PM10/27/15
to Dong Zhen, Caffe Users

For me this fixed it:


after installing libjpeg-devel, try re-installing pillow , like "pip install -I pillow"

If you're getting a different error message copy and paste it to me and I will take a look


--
You received this message because you are subscribed to a topic in the Google Groups "Caffe Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/caffe-users/ltdeqU4hiaw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/a3fae3b1-3001-4934-91ac-e8d41efa030b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dong Zhen

unread,
Oct 27, 2015, 10:26:15 PM10/27/15
to Caffe Users, cndon...@gmail.com
Thank you for your kind reply. I tried, but it still reports the error.
The error is as follows:

imagedata = caffe.io.load_image(IMAGE_FILE)
  File "/usr/lib/python2.7/site-packages/caffe/io.py", line 288, in load_image
    img = skimage.img_as_float(skimage.io.imread(filename)).astype(np.float32)
  File "/usr/lib64/python2.7/site-packages/skimage/io/_io.py", line 100, in imread
    img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
  File "/usr/lib64/python2.7/site-packages/skimage/io/manage_plugins.py", line 207, in call_plugin
    return func(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/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 "images/cat_gray.jpg"
terminal called after throwing an instance of 'boost::python::error_already_set'



I write a data layer in python ('d.py'), and embed it into the 'layer_factory.cpp' by using boost::python.
In the python terminal, I am able to conduct d.py successfully, but in this way it failed.
Thank you.




在 2015年10月28日星期三 UTC+8上午12:21:20,Matt Hill写道:

Bjørn Rustad

unread,
Oct 28, 2015, 10:41:16 AM10/28/15
to caffe...@googlegroups.com
On Wed, Oct 28, 2015, at 03:26, Dong Zhen wrote:
> *I write a data layer in python ('d.py'), and embed it into the
> 'layer_factory.cpp' by using boost::python.*
> *In the python terminal, I am able to conduct d.py successfully, but in
> this way it failed.*
> *Thank you.*

The current working directory is probably different when you run Python
in the terminal and when you run it through C++, so that it cannot find
the image. Try printing the current working directory in you Python
script.

Also, caffe has support for Python layers. You may want to look into
that.

--
Bjørn Rustad
bj...@rustad.me

Dong Zhen

unread,
Oct 28, 2015, 10:14:18 PM10/28/15
to Caffe Users, bj...@rustad.me
Thank you. The error was occured when I run the code of the activity experiment of "Long-term Recurrent Convolutional Networks for Visual Recognition and Description"(CVPR,2015)(http://jeffdonahue.com/lrcn/), they use the Caffe supported python layers to load data by 'sequence_input_layer.py'.
But when I ran this code, the error occurs. Thank you.

在 2015年10月28日星期三 UTC+8下午10:41:16,Bjørn Rustad写道:
Reply all
Reply to author
Forward
0 new messages