RuntimeError while opening deploy.prototxt

350 views
Skip to first unread message

Ehab Albadawy

unread,
Apr 24, 2016, 4:33:40 PM4/24/16
to Caffe Users
Question on stackoverflow



I'm trying run a simple code with caffe that should open deploy.prototxt but it couldn't open the file and throws this error


RuntimeError: Could not open file /home/ebadawy/git/caffemodels/bvlc_reference_caffenet/deploy.prototxt


this is my code


import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['figure.figsize'] = (10, 10)        # large images
plt.rcParams['image.interpolation'] = 'nearest'  # don't interpolate:     show square pixels
plt.rcParams['image.cmap'] = 'gray'  # use grayscale output rather than a (potentially misleading)
                                     # color heatmap
caffe_root = '/home/ebadawy/git/caffe'

import os
if os.path.isfile(caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel'):
    print('CaffeNet found.')
else:
    print('Downloading pre-trained CaffeNet model...')
    os.system('../scripts/download_model_binary.py ../models/bvlc_reference_caffenet')

import caffe

caffe.set_mode_cpu()
model_def = caffe_root + 'models/bvlc_reference_caffenet/deploy.prototxt'
model_weights = caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel'

net = caffe.Net(model_def,      # defines the structure of the model
            model_weights,  # contains the trained weights
            caffe.TEST)     # use test mode (e.g., don't perform dropout)


I'm using archlinux+python3.5

Ahmed Ibrahim

unread,
Apr 25, 2016, 1:12:09 PM4/25/16
to Caffe Users
Hi Ehab,
please change the caffe_root to be
caffe_root = '/home/ebadawy/git/caffe/'
adding the backslash at the end will make the path refer to
caffe/models instead of caffemodels
  please review your code very well before running it , you are lucky you got an error.
sometimes you do not get any errors but also you do not get any good results because something wrong in your code.
Good luck .
Reply all
Reply to author
Forward
0 new messages