RuntimeError while opening deploy.prototxt

为君一笑 提交于 2019-12-10 17:49:05

问题


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


回答1:


I found that I forgot to append / for caffe_root "very silly mistake!"




回答2:


add backslash at the end of your caffe_root like

caffe_root = '/home/ebadawy/git/caffe/'

I guess your path should refer to caffe/models , not caffemodels. Good luck




回答3:


I solved this using the absolute path to the directory that contained the deploy.prototxt file.



来源:https://stackoverflow.com/questions/36828380/runtimeerror-while-opening-deploy-prototxt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!