在运行optimize_for_inference.py时,如何修复“ google.protobuf.message.DecodeError:错误解析消息”

时间:2019-01-30 12:20:43

标签: android python tensorflow image-segmentation

我正在自定义数据集中训练mobilenet_v1_1.0_224。我已经生成了所需的graph.pb文件,并希望在android应用中运行模型。试图运行optimize_for_inference.py生成优化的文件,但出现错误消息-google.protobuf.message.DecodeError: Error parsing message

我检查了protobuf安装,它已经存在。我正在运行以下-

!python tensorflow/tensorflow/python/tools/optimize_for_inference.py \
--input = model_output/graph_v1.pb \
--output = model_output/optimized_graph_v1.pb \
--input_names = input \
--output_names = MobilenetV1/Predictions/Reshape_1

输出:

Traceback (most recent call last):
  File "tensorflow/tensorflow/python/tools/optimize_for_inference.py", line 165, in <module>
    app.run(main=main, argv=[sys.argv[0]] + unparsed)
  File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "tensorflow/tensorflow/python/tools/optimize_for_inference.py", line 83, in main
    input_graph_def.ParseFromString(data)
google.protobuf.message.DecodeError: Error parsing message

Am使用tensorflow版本1.4.0

1 个答案:

答案 0 :(得分:0)

在将值传递给参数时,我删除了'='前后的空格。现在可以正常使用