RuntimeError: Could not open file SqueezeNet_deploy.prototxt

运行caffe代码时,加载模型prototxt文件:

import sys
import os
import numpy as np
import pickle

help_ = '''
Usage:

    decode.py   
    Set variable CAFFE_ROOT as root of caffe before run this demo!
'''

if len(sys.argv) != 4:
    print help_
    sys.exit()
else:
    prototxt = sys.argv[1]
    net_bin = sys.argv[2]
    target = sys.argv[3]

# os.system("cd $CAFFE_ROOT")
caffe_root = os.environ["CAFFE_ROOT"]
os.chdir(caffe_root)
print caffe_root
sys.path.insert(0, caffe_root + 'python')
import caffe

caffe.set_mode_cpu()
net = caffe.Net(prototxt, caffe.TEST)
输入参数设置为:

export CAFFE_ROOT=/home/caffe/
prototxt=SqueezeNet_deploy.prototxt
 
  
运行后出现错误:

RuntimeError: Could not open file SqueezeNet_deploy.prototxt

查看原因是因为prototxt文件路径需要为绝对路径,因此将输入改为:

prototxt=/home/SqueezeNet/SqueezeNet_deploy.prototxt
修改后,运行正确:

RuntimeError: Could not open file SqueezeNet_deploy.prototxt_第1张图片


你可能感兴趣的:(编程语言)