Closed liuguoyou closed 7 years ago
@liuguoyou 这个出错信息的意思是你没有安装 Python caffe module,需要你用原始的 caffe 代码编译安装。使用 protobin 能够大幅度缩小 app 的大小,并且提升初始化速度。
也可以把build/include/caffe/proto/caffe_pb2.py拷贝到tools路径下,修改prototxt2bin.py为:
#!/usr/bin/env python
import sys
from os import path
import caffe_pb2
from google.protobuf import text_format
if len(sys.argv) < 2:
print("Usage: ./prototxt2bin.py net.prototxt")
for filename in sys.argv[1:]:
basename, extname = path.splitext(filename)
if extname == '.prototxt':
print("Read Caffe net text from: " + filename)
params = caffe_pb2.NetParameter()
with open(filename, 'rt') as f:
text_format.Merge(f.read(), params)
print("Write Caffe net binary to: " + basename + '.protobin')
with open(basename + '.protobin', 'wb') as f:
f.write(params.SerializeToString())
运行即可
@yanghuanflc 非常感谢,而且我觉得不用拷贝文件,可以直接用 importlib 。既然是你的提议,不知是否愿意发个 pull request?
tools/prototxt2bin.py ImportError: No module named caffe.proto
cafffe的prototxt 不能直接跑吗