所以我正在关注sentdex的对象检测教程,我已经到了你应该导出推理图的步骤。我正在使用Tensorflow的object_detection文件夹中的“export_inference_graph.py”脚本。 问题是我得到了这个ValueError:
Traceback (most recent call last):
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\google\proto
buf\internal\python_message.py", line 545, in _GetFieldByName
return message_descriptor.fields_by_name[field_name]
KeyError: 'layout_optimizer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "export_inference_graph.py", line 119, in <module>
tf.app.run()
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\p
ython\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "export_inference_graph.py", line 115, in main
FLAGS.output_directory, input_shape)
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detec
tion-0.1-py3.5.egg\object_detection\exporter.py", line 427, in export_inference_graph
input_shape, optimize_graph, output_collection_name)
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detec
tion-0.1-py3.5.egg\object_detection\exporter.py", line 391, in _export_inference_graph
initializer_nodes='')
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\object_detec
tion-0.1-py3.5.egg\object_detection\exporter.py", line 72, in freeze_graph_with_def_protos
layout_optimizer=rewriter_config_pb2.RewriterConfig.ON)
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\google\proto
buf\internal\python_message.py", line 484, in init
field = _GetFieldByName(message_descriptor, field_name)
File "C:\Users\Zelcore-Dator\AppData\Local\Programs\Python\Python35\lib\site-packages\google\proto
buf\internal\python_message.py", line 548, in _GetFieldByName
(message_descriptor.name, field_name))
ValueError: Protocol message RewriterConfig has no "layout_optimizer" field.
我猜它与protobuf有关,但我已经多次重新安装它并没有成功。 所有帮助表示赞赏
答案 0 :(得分:5)
也发生在我身上。几周前没有发生过。 在修复错误之前,您可以使用仍然有效的早期版本。 替换'object_detection / exporter.py'中的第72行:
layout_optimizer=rewriter_config_pb2.RewriterConfig.ON)
旧的和工作线:
optimize_tensor_layout=True)
答案 1 :(得分:1)
我用过:
rewrite_options = rewriter_config_pb2.RewriterConfig(optimize_tensor_layout=True)
但仍然遇到了同样的问题,直到我去了并重新开始
python setup.py install
来自我的&#34;研究&#34;夹。然后我就能把一切都搞定了。
答案 2 :(得分:1)
删除 optimize_tensor_layout = rewriter_config_pb2.RewriterConfig.ON
更改exporter.py
rewrite_options = rewriter_config_pb2.RewriterConfig(optimize_tensor_layout=rewriter_config_pb2.RewriterConfig.ON)
为:
rewrite_options = rewriter_config_pb2.RewriterConfig()