Joe C
Joe C

Reputation: 47

Export inference graph - valueerror: the passed save_path is not a valid checkpoint:

Thanks for any help you can give. Here is my code to setup variables and paths:

# 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)

And here is my code to exporting the inference graph:

!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

I get the following error:

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: 

I've tried playing around with the paths, to make sure there were no errors there. I've looked at similar threads and followed suggestions there but all other threads the valueerror points to specific path/file, where as this doesn;t??? PLease help if you can.

Upvotes: 1

Views: 905

Answers (1)

Jak
Jak

Reputation: 177

sorry for the late response but I hope I can still help you. I had the same problem. The reason why you get this error is because when you cancelled training your neural network, not all data has beem written to the file. Therefore, it is inconsistent. You can easily solve this by using a model with a lower number. Example: my highest number is 640. The second highest number is 417. Model.ckpt-640 is inconsistent, therfore I will export the graph using model.ckpt-417

Upvotes: 2

Related Questions