gpt4 book ai didi

python - 打开 deploy.prototxt 时出现 RuntimeError

转载 作者:行者123 更新时间:2023-11-28 19:13:26 25 4
gpt4 key购买 nike

我正在尝试使用 caffe 运行一个简单的代码,它应该打开 deploy.prototxt 但它无法打开文件并抛出此错误

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

这是我的代码

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)

我用的是archlinux+python3.5

最佳答案

我发现我忘记为 caffe_root 添加 / “非常愚蠢的错误!”

关于python - 打开 deploy.prototxt 时出现 RuntimeError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36828380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com