Models: Error while exporting inference graph.

Created on 21 Nov 2017  路  18Comments  路  Source: tensorflow/models

After pulling repo (0cc986287ca655ac0c675870a22ea90fdb3c4ece) got an error on object_detection/export_inference_graph.py call.
Error message:
File "/home/ubuntu/models/research/object_detection/exporter.py", line 72, in freeze_graph_with_def_protos optimize_tensor_layout=True) ValueError: Protocol message RewriterConfig has no "optimize_tensor_layout" field
TF version: latest nightly build

help wanted

Most helpful comment

on ubuntu 16.04 with latest version of everything involved installed I got the same error:

ValueError: Protocol message RewriterConfig has no "layout_optimizer" field.

I changed "layout_optimizer" to "optimize_tensor_layout" on line 72 in exporter.py, and then it worked.

(I'm guessing that RewriterConfig needs to be updated if the desired name of the field is "layout_optimizer" and not "optimize_tensor_layout")

All 18 comments

some error on export_inference_graph.py (tf1.4, cuda9)
this changes in exporter.py not solve rewrite_options = rewriter_config_pb2.RewriterConfig(layout_optimizer=rewriter_config_pb2.RewriterConfig.ON)

File "export_inference_graph.py", line 119, in
tf.app.run()
File "/home/leo/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 129, in run
_sys.exit(main(argv))
File "export_inference_graph.py", line 115, in main
FLAGS.output_directory, input_shape)
File "/home/leo/tf/models/research/object_detection/exporter.py", line 427, in export_inference_graph
input_shape, optimize_graph, output_collection_name)
File "/home/leo/tf/models/research/object_detection/exporter.py", line 391, in _export_inference_graph
initializer_nodes='')
File "/home/leo/tf/models/research/object_detection/exporter.py", line 71, in freeze_graph_with_def_protos
rewrite_options = rewriter_config_pb2.RewriterConfig(optimize_tensor_layout=True,layout_optimizer=rewriter_config_pb2.RewriterConfig.ON)
File "/home/leo/.local/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 496, in init
field = _GetFieldByName(message_descriptor, field_name)
File "/home/leo/.local/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 560, in _GetFieldByName
(message_descriptor.name, field_name))
ValueError: Protocol message RewriterConfig has no "optimize_tensor_layout" field.

Getting the same error. Any solutions?

I resolved it by removing "optimize_tensor_layout=True" from exporter.py line 71. It looks like a tensorflow bug but for now that worked.

tks mahyarr, remove "optimize_tensor_layout=True" from exporter.py line 71. solved!!!

Change the parameter on line 71 to layout_optimizer=1 . Made a PR - #3106

For me it still throws the error even though I'm using the current standard value for the parameter, any tips?

on ubuntu 16.04 with latest version of everything involved installed I got the same error:

ValueError: Protocol message RewriterConfig has no "layout_optimizer" field.

I changed "layout_optimizer" to "optimize_tensor_layout" on line 72 in exporter.py, and then it worked.

(I'm guessing that RewriterConfig needs to be updated if the desired name of the field is "layout_optimizer" and not "optimize_tensor_layout")

Hmm, I tried changing line 72 to that but I still get the exact same error lol. There has to be some weird stuff going on for me right now...

@frostell that work, thank you!!!

On Ubuntu 16.04; Changing layout_optimizer in export.py didn't fix the problem, I still get the error:

ValueError: Protocol message RewriterConfig has no "layout_optimizer" field.

@frostell How can I update RewiterConfig? Thanks in advance

thanks @frostell - faced the same problem and it worked well for me!

Thank you @frostell 馃

The fix you suggested did it for me too. During my initial setup, I had to run the following commands referenced from the link below:

cd model/research/

python setup.py build
python setup.py install

So, once I applied the fix you suggested, and re-run ^ commands to get the export working.

Using the stock tensorflow models clone I'm getting the same error pretty much everybody else here is describing. While attempting to follow this tutorial series:

https://www.youtube.com/playlist?list=PLQVvvaa0QuDcNK5GeCQnxYnSSaar2tpku

In the 6th video, when I run export_inference_graph.py with the stock tensorflow models clone, I get this error:

ValueError: Protocol message RewriterConfig has no "layout_optimizer" field.

If I change models/research/object_detection/exporter.py line 71/72 from

rewrite_options = rewriter_config_pb2.RewriterConfig(
          layout_optimizer=rewriter_config_pb2.RewriterConfig.ON)

to

rewrite_options = rewriter_config_pb2.RewriterConfig()

and I don't change anything else whatsoever and run it again then it works.

I'm running Windows 10, TensorFlow 1.4, and I cloned tensorflow models and performed the protobuf compile this past weekend so I'm confident they are both current.

Somebody at google please fix this asap.

I also changed "layout_optimizer" to "optimize_tensor_layout" on line 72 in exporter.py, and then it worked.

However, why has this problem not been fixed?

Thanks,

ok, seems like the RewriterConfig has been changed in tensorflow 1.5 and the small modification detailed above will make it brake in the same manner but with the opposite result (I had to change back from the small mod when I updated to 1.5)

what will work is:

Tensorflow version 1.4
"optimize_tensor_layout" on line 72 in exporter.py

Tensorflow version 1.5
"layout_optimizer" on line 72 in exporter.py

@frostell thanks that fixed it!

@frostell, thank you that fixed it on

Ubuntu 16.04.01 LTS
Tensorflow 1.4.1

Closing as this is resolved

Was this page helpful?
0 / 5 - 0 ratings