在Ubuntu 14.04上运行deepdream时出错

时间:2015-07-07 17:31:11

标签: python ubuntu anaconda

当我在Ubuntu 14.04上运行deep dream时,出现此错误:

Traceback (most recent call last):
  File "dream.py", line 7, in <module>
from google.protobuf import text_format
ImportError: No module named google.protobuf

当我运行python --version时,我明白了:

Python 2.7.10 :: Anaconda 2.3.0 (64-bit)

我确保遵循安装说明并安装了所有依赖项。我不知道为什么我会收到此错误,但感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

n用于在protobuf文件中添加一行。 你可以添加一行: deploy.prototxtforce_backward: true并删除该依赖项。

您必须更改以下代码:

deploy.prototxt

为:

model = caffe.io.caffe_pb2.NetParameter()
text_format.Merge(open(net_fn).read(), model)
model.force_backward = True
open('tmp.prototxt', 'w').write(str(model))

net = caffe.Classifier('tmp.prototxt', param_fn,
                       mean = np.float32([104.0, 116.0, 122.0]), # ImageNet mean, training set dependent
                       channel_swap = (2,1,0)) # the reference model has channels in BGR order instead of RGB

并删除行

net = caffe.Classifier(net_fn, param_fn,
                       mean = np.float32([104.0, 116.0, 122.0]), # ImageNet mean, training set dependent
                       channel_swap = (2,1,0)) # the reference model has channels in BGR order instead of RGB

<小时/> 如果您只想尝试深度梦,请查看deepdreamer