在 Ubuntu 14.04 上 运行 deepdream 时出错
Error when running deepdream on Ubuntu 14.04
当我 运行 deep dream 在 Ubuntu 14.04 上出现此错误时:
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)
我已确保按照安装说明安装了所有依赖项。我不确定为什么会收到此错误,但我们将不胜感激。
protobuf
用于将单行添加到 deploy.prototxt
文件中。
您只需添加以下行:
force_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
并删除行
from google.protobuf import text_format
如果你只是想试试 deepdream,看看 deepdreamer
当我 运行 deep dream 在 Ubuntu 14.04 上出现此错误时:
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)
我已确保按照安装说明安装了所有依赖项。我不确定为什么会收到此错误,但我们将不胜感激。
protobuf
用于将单行添加到 deploy.prototxt
文件中。
您只需添加以下行:
force_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
并删除行
from google.protobuf import text_format
如果你只是想试试 deepdream,看看 deepdreamer