Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

google.protobuf.message.DecodeError: Error parsing message with type 'tensorflow.GraphDef'

Ask Question

I was training the model and saved it, now I am trying to load but unable to do. I have seen in previous post as well, but some reference links are not working or some things I tried, still not able to solve the problem.

Code snippet:

#load model
with tf.io.gfile.GFile(args.model, "rb") as f:
    graph_def = tf.compat.v1.GraphDef()
    graph_def.ParseFromString(f.read())
# with tf.Graph().as_default() as graph:
generated_image_1, generated_image_2, generated_image_3, = tf.graph_util.import_graph_def(
        graph_def, 
        input_map={'input_image' : input_tensor, 'short_edge_1' : short_edge_1, 'short_edge_2' : short_edge_2, 'short_edge_3' : short_edge_3}, 
        return_elements=['style_subnet/conv-block/resize_conv_1/output:0', 'enhance_subnet/resize_conv_1/output:0', 'refine_subnet/resize_conv_1/output:0'],  
        producer_op_list=None

Error

Traceback (most recent call last):
  File "stylize.py", line 97, in <module>
    main()
  File "stylize.py", line 57, in main
    graph_def.ParseFromString(f.read())
google.protobuf.message.DecodeError: Error parsing message with type 'tensorflow.GraphDef'

Note: If need more information about this, will sure post add it here. Let me know

BG: I was getting errors while testing the code. In my case, it was solved with the help of freeze.py and a few modifications in the training file. And I found some other useful links while searching query. Link 1

Link 2

I have error here: ---> 34 od_graph_def.ParseFromString(serialized_graph) DecodeError: Error parsing message I cannot find a solution in the above 2 links...Can someone help? – just_learning Jul 30, 2022 at 12:48

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.