.ckpt文件转换为tensorflow可用的目标检测.pb模型文件
2018年12月22日 2018年12月31日
生成.pb文件:
在 models-master\research\object_detection文件夹下找到 export_inference_graph.py 文件,要运行这个文件,还需要传入config以及checkpoint的相关参数。
定位到 models-master\research\object_detection 文件夹下,运行:
1 |
python export_inference_graph.py --input_type image_tensor --pipeline_config_path=F:\labelImg\tfrecords\hand\ssd_mobilenet_v1_coco.config --trained_checkpoint_prefix=F:\labelImg\tfrecords\hand\ckpt\model.ckpt-25 --output_directory=F:\labelImg\tfrecords\hand\pb |
–trained_checkpoint_prefix model.ckpt-25 这个checkpoint(.ckpt-后面的数字)可以在hand\ckpt文件夹下找到你自己训练的模型,填上对应的数字(如果有多个,选最大的)
报错:ValueError: The passed save_path is not a valid checkpoint: F:\labelImg\tfrecords\hand\ckpt\model.ckpt-0
解决:路径中的“\\”问题
把–trained_checkpoint_prefix F:\\labelImg\\tfrecords\\hand\\ckpt\\model.ckpt-0
改成–trained_checkpoint_prefix F:\labelImg\tfrecords\hand\pb\handpb\model.ckpt-0
成功后“pb”目录文件结构如下: