pycaffe error: RuntimeError: Could not open file ~/caffe/examples/mnist/lenet.prototxt

891 views
Skip to first unread message

SRQ

unread,
May 9, 2016, 11:01:39 AM5/9/16
to Caffe Users
I am getting started with pycaffe and trying to use various commands as given here. This is the simple code I have written to just load a net.

#activate CPU mode
caffe
.set_mode_cpu()

#path of files
deploy_file_path
= '~/caffe/examples/mnist/lenet.prototxt'
weights_file_path
= '~/caffe/examples/mnist/lenet_iter_5000.caffemodel'

#load a net
net
= caffe.Net(deploy_file_path, weights_file_path, caffe.TEST)

However when I try to execute this I get the error:

Traceback (most recent call last):
 
File "/home/xx/caffe/python/xxx.py", line 22, in <module>
    net
= caffe.Net(deploy_file_path, weights_file_path, caffe.TEST)
RuntimeError: Could not open file ~/caffe/examples/mnist/lenet.prototxt

I think I am missing something really basic here. Can someone explain my ignorance to me?

Hossein Hasanpour

unread,
May 10, 2016, 3:25:13 AM5/10/16
to Caffe Users
check your path! it clearly is saying it can not find the path. 
try using a full path (ie. not relative) and see if the problem persists . 

SRQ

unread,
May 10, 2016, 3:32:13 AM5/10/16
to Caffe Users
It is certainly not the path, I have rechecked it many times as that was what I suspected too.

Jan

unread,
May 10, 2016, 5:27:02 AM5/10/16
to Caffe Users
You cannot use '~' in these paths. The '~' sign (meaning the home folder) is interpreted by the shell, i.e. bash replaces ~ with your home path whenever you give it in a command. But here is no shell involved, so you need to give paths without these abbreviations and wildcards. Note that '.' and '..' are different, these are really features of the filesystem, not of the shell. See the first few sentences here, for instance: https://docs.python.org/2.7/library/os.path.html.

Jan

SRQ

unread,
May 10, 2016, 6:30:12 AM5/10/16
to Caffe Users
Yes I found the exact same thing. Replacing it with manual path works fine. Thank you!
Reply all
Reply to author
Forward
0 new messages