Caffe 到 Tensorflow(Ethereon 的 Kaffe):类型错误:不应直接创建描述符,而只能从其父项中检索

jea*_*ean 4 protocol-buffers python-2.7 caffe tensorflow

我想使用 ethereon 的精彩包 caffe-tensorflow,但遇到了这个已关闭问题中描述的相同问题 :

当我运行示例或尝试时,import caffepb我收到错误消息:

>>> import caffepb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "caffepb.py", line 28, in <module>
        type=None),
  File "/home/me/anaconda/python2.7/site-packages/google/protobuf/descriptor.py", line 652, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors should not be created directly, but only retrieved from their parent.
Run Code Online (Sandbox Code Playgroud)

我在带有 protobuf 3.0.0b2.post(但它也发生在 3.0.0a4 和 3.0.0b2 上)的 Linux 64 位 UBUNTU 14.04 机器上使用 Tensorflow 0.7.0 和 Python 2.7 和 anaconda。

我多次尝试重新安装 protobuf 和 tensorflow,因为我认为这很可能是不同 protobuf 安装之间的冲突(或者至少这是 github 问题的结论),但即使在组合 pip 之后我也无法使其工作安装protobuf,pip卸载protobuf或者直接安装protobuf .whl。

你有什么建议?

编辑:使用虚拟环境可能是一个解决方案,但我想尽可能避免它

Kai*_* Yu 8

将任何创建描述符的文件重命名为具有后缀“_pb2.py”将解决此问题。

更新(2017 年 4 月 4 日):在“caffe-tensorflow”项目中,我将“kaffe/caffe/caffepb.py”重命名为“caffe_pb2.py”,这解决了问题。这是我在这个项目中找到的唯一一个创建 PB 描述符的文件。