【问题标题】:Caffe to Tensorflow (Kaffe by Ethereon) : TypeError: Descriptors should not be created directly, but only retrieved from their parentCaffe to Tensorflow (Kaffe by Ethereon) : TypeError: Descriptors should not be created, but only retrieved from their parent
【发布时间】:2016-07-27 14:58:51
【问题描述】:

我想使用 ethereon 的精彩包 caffe-tensorflow,但遇到了相同的问题 this closed issue

当我运行示例或尝试 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.

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

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

你有什么建议?

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

【问题讨论】:

    标签: python-2.7 tensorflow caffe protocol-buffers


    【解决方案1】:

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

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

    【讨论】:

    • 非常有趣的解决方案,如果属实,我会尽快尝试!
    • 您能说得更具体些吗?您是在谈论存储库中的文件还是系统中安装的文件?
    【解决方案2】:

    我也遇到了同样的问题。我的解决方案(解决方法)与问题中的一个 cmets 相同 - 在 virtualenv 中安装/运行 tf 和 protobuf3(以及任何东西)

    我不知道到底是什么问题。这只是您可以尝试的一种解决方法。

    【讨论】:

    • 感谢您的回答,但这个解决方法已经在 github 问题中提到,并没有说服我,因为它太激进了。
    【解决方案3】:

    Kai Yu 的解决方案也对我有用。但是,我还建议删除 caffe-tensorflow/kaffe/caffe 中的“caffepb.pyc”文件,以确保没有代码仍然可以使用旧名称的 caffe_pb2 模块。

    我相信这个模块只用在文件caffe-tensorflow/kaffe/caffe/resolver.py中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-20
      • 2020-10-08
      • 1970-01-01
      • 2022-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-01
      相关资源
      最近更新 更多