导出推断图-ValueError:传递的save_path不是有效的检查点:

问题描述

感谢您提供的任何帮助。 这是我的设置变量和路径的代码

# by Chengwei
#dir where the model will be saved
output_directory = './fine_tuned_model'

lst = os.listdir('training')
lst = [l for l in lst if 'model.ckpt-' in l and '.Meta' in l]
steps=np.array([int(re.findall('\d+',l)[0]) for l in lst])
last_model = lst[steps.argmax()].replace('.Meta','')

last_model_path = os.path.join('/training/',last_model)
print(last_model_path)

这是我导出推理图的代码

!python /content/drive/'My Drive'/object_detection/models/research/object_detection/export_inference_graph.py \
    --input_type image_tensor \
    --pipeline_config_path /content/drive/'My Drive'/object_detection/models/research/object_detection/samples/configs/export_graph_ssd_mobilenet_v2_coco.config \
    --output_directory output_directory \
    --inference_graph_path output_inference_graph \
    --trained_checkpoint_prefix last_model_path

我收到以下错误

Traceback (most recent call last):
  File "/content/drive/My Drive/object_detection/models/research/object_detection/export_inference_graph.py",line 83,in <module>
    tf.app.run()
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/platform/app.py",line 40,in run
    _run(main=main,argv=argv,flags_parser=_parse_flags_tolerate_undef)
  File "/usr/local/lib/python3.6/dist-packages/absl/app.py",line 299,in run
    _run_main(main,args)
  File "/usr/local/lib/python3.6/dist-packages/absl/app.py",line 250,in _run_main
    sys.exit(main(argv))
  File "/content/drive/My Drive/object_detection/models/research/object_detection/export_inference_graph.py",line 79,in main
    FLAGS.inference_graph_path)
  File "/content/drive/My Drive/object_detection/models/research/object_detection/exporter.py",line 625,in export_inference_graph
    side_input_types=side_input_types)
  File "/content/drive/My Drive/object_detection/models/research/object_detection/exporter.py",line 538,in _export_inference_graph
    trained_checkpoint_prefix=checkpoint_to_use)
  File "/content/drive/My Drive/object_detection/models/research/object_detection/exporter.py",line 423,in write_graph_and_checkpoint
    saver.restore(sess,trained_checkpoint_prefix)
  File "/tensorflow-1.15.2/python3.6/tensorflow_core/python/training/saver.py",line 1282,in restore
    checkpoint_prefix)
ValueError: The passed save_path is not a valid checkpoint: 

我尝试使用这些路径,以确保其中没有错误。我看过类似的线程,并在其中遵循了建议,但是valueerror指向所有其他线程的特定路径/文件,因为这里没有; t ??? 如果可以,请帮助。

解决方法

对不起,您的回复很晚,但希望我能为您提供帮助。 我有同样的问题。出现此错误的原因是,当您取消训练神经网络时,并非所有数据都已写入文件。因此,这是不一致的。您可以使用数字较小的模型轻松解决此问题。例如:我的最高编号是640。第二高的编号是417。Model.ckpt-640不一致,因此我将使用model.ckpt-417

导出图形