从Checkpoint和Meta还原Tensorflow 2.1训练模型以进行推理

时间:2020-04-07 00:43:52

标签: tensorflow model restore valueerror checkpoint

我正在尝试使用在https://github.com/shahrukhqasim/TIES-2.0中实现的模型来查找“文档”中图像中的行和列。他们将带注释的(针对行和列的)表转换为tfrecord,然后使用Tensorflow训练CNN。在训练期间,对输出文件的配置设置如下:

summary_path=C:\projects\testing\TIES-2.0\python\summary4\
model_path=C:\projects\testing\TIES-2.0\python\mdl4\
test_out_path=C:\projects\testing\TIES-2.0\python\test4\
profiler_output_file_name=C:\projects\testing\TIES-2.0\python\profiler4
visual_feedback_out_path=C:\projects\testing\TIES-2.0\python\visual_feedback4

培训顺利完成后,我在文件夹C:\projects\testing\TIES-2.0\python\mdl4\中创建了以下文件:

enter image description here

和同一目录中的单独summary4文件夹,该文件夹具有以下输出(训练进行了三遍):

enter image description here

test4文件夹为空,visual_feedback4的pdf内部带有注释。 使用先前在github(how to predict with .meta and checkpoint files in tensorflow?Use .ckpt and .meta -files to make predictions with Inception in TensorFlow)上回答的问题,我尝试了以下代码来恢复模型以进行预测:

import tensorflow.compat.v1 as tf
model_path = r"C:\projects\testing\TIES-2.0\python\mdl4"
detection_graph = tf.Graph()
with tf.Session(graph=detection_graph) as sess:
    # Load the graph with the trained states
    loader = tf.train.import_meta_graph(model_path+'\.meta')
    #loader.restore(sess, model_path)
    loader.restore(sess, r"C:\projects\testing\TIES-2.0\python\mdl4\.checkpoint.ckpt")

哪个立即给我错误:

ValueError: The passed save_path is not a valid checkpoint: C:\projects\testing\TIES-2.0\python\mdl4\.checkpoint.ckpt

已尝试将文档中的另一个文件用作loader.restore的参数,因为loader本身运行没有问题。感谢您的帮助,已经有一个星期了。

0 个答案:

没有答案