导出推断图-ValueError:传递的save_path不是有效的检查点: [英] 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
我收到以下错误:
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 ??? 如果可以,请帮助.
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.
推荐答案
很抱歉,您的回复很晚,但是希望我能为您提供帮助. 我有同样的问题.出现此错误的原因是,当您取消训练神经网络时,并不是所有数据都已写入文件.因此,这是不一致的.您可以使用数字较小的模型轻松解决此问题.例如:我的最高编号是640.第二高的编号是417.Model.ckpt-640不一致,因此我将使用model.ckpt-417
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
这篇关于导出推断图-ValueError:传递的save_path不是有效的检查点:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!