Home > Back-end >  google.protobuf.message.DecodeError: Error parsing message with type 'tensorflow.GraphDef'
google.protobuf.message.DecodeError: Error parsing message with type 'tensorflow.GraphDef'

Time:03-20

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

CodePudding user response:

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

  • Related