google.protobuf.message.DecodeError:解析类型为“tensorflow.GraphDef”的消息时出错

sub*_*bbu 6 python image-processing deep-learning tensorflow tensorboard

我正在训练模型并保存它,现在我尝试加载但无法执行。我也在之前的帖子中看到过,但是一些参考链接不起作用,或者我尝试了一些方法,仍然无法解决问题。

代码片段:

#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
    )
Run Code Online (Sandbox Code Playgroud)

错误

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'
Run Code Online (Sandbox Code Playgroud)

注意:如果需要更多相关信息,请务必在此处添加。让我知道

sub*_*bbu 2

BG:我在测试代码时遇到错误。就我而言,它是在 freeze.py 的帮助下解决的,并对训练文件进行了一些修改。我在搜索查询时发现了一些其他有用的链接。 链接1

链接2