将Caffe Prototxt文件转换为TensorFlow

时间:2019-06-11 02:20:03

标签: python tensorflow deep-learning caffe

我有一个定义caffe模型的prototxt文件,其示例粘贴在下面。我想要一个可以解析此文件并在python tensorflow中生成代码的脚本,该文件可以设置这些层并将其连接为该文件。

我在此Eliot Andres博客文章https://ndres.me/post/convert-caffe-to-tensorflow/

中试用了caffe-tensorflow软件包

我实际上没有使用caffe训练任何模型,我希望直接在tensorflow中训练它们。因此,我尝试运行此命令:

python caffe-tensorflow/convert.py file.prototxt --code-output-path ./output.py

引发错误:

Traceback (most recent call last):
  File "caffe-tensorflow/convert.py", line 130, in <module>
    main()
  File "caffe-tensorflow/convert.py", line 126, in main
    args.standalone_output_path, args.phase)
  File "caffe-tensorflow/convert.py", line 32, in convert
    transformer = TensorFlowTransformer(def_path, caffemodel_path, phase=phase)
  File "/home/home1/user/tensorflow_translation/caffe-tensorflow/kaffe/tensorflow/transformer.py", line 221, in __init__
    self.load(def_path, data_path, phase)
  File "/home/home1/user/tensorflow_translation/caffe-tensorflow/kaffe/tensorflow/transformer.py", line 227, in load
    graph = GraphBuilder(def_path, phase).build()
  File "/home/home1/user/tensorflow_translation/caffe-tensorflow/kaffe/graph.py", line 209, in build
    layers = self.filter_layers(layers)
  File "/home/home1/user/tensorflow_translation/caffe-tensorflow/kaffe/graph.py", line 168, in filter_layers
    assert layer.name not in filtered_layer_names
AssertionError```


Snippet from file.prototxt:

```python
name: "OSVOS"
layer {
  name: "data"
  type: "Python"
  top: "data"
  top: "label"
  top: "mbcat"
  top: "of"
  top: "dt"
  top: "label_dt"
  include {
    phase: TRAIN
  }
  python_param {
    module: "needle_input_layer_batch_celoss_dt_side"
    layer: "OSVOSDataLayer"
    param_str: "{\'data_root_dir\': \'/usr/xtmp/user/DATA/DAVIS/DAVIS-2017-trainval-480p/\', \'seed\': 1337,\'pair_list\':\'./solvers/train_6_dt.txt\',\'batchSize\':8}"
  }
}

有人可以帮助我如何正确使用caffe-tensorflow软件包,或者将我指向可以执行此操作的任何其他软件包吗?非常感谢。

0 个答案:

没有答案