TensorFlow models object_detection目标检测解析
简介
- TensorFlow的models中集合了近年来深度学习在各种领域上的应用。这里讲述其中的目标识别object_detection目标检测的使用以及踩得坑。
- 链接:https://github.com/tensorflow/models/tree/master/research/object_detection
- 在默认配置好环境的条件下(安装TensorFlow,Python及相关库),download上述链接到本地。
1、用软件labelme或者labelimg制作自己的数据集
2、用xml_to_csv.py将数据集转为CSV格式
3、修改generate_tfrecord.py
对应位置修改为自己要识别的类别
在对应生成labelmap.pbtxt
之后运行generate_tfrecord.py,生成tfrecord
4、在configs文件夹中找配置文件,修改参数
参数教程
在g3doc里有讲解。
使用fine_tune,下载预训练模型
下载的预训练模型要删除checkpoint才行。
5、运行train.py训练
示例:
–logtostderr
–train_dir=D:\Jupyter\TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10-master\SSD_2019_11_4
–pipeline_config_path=D:\Jupyter\TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10-master\SSD_2019_11_4\faster_rcnn_inception_v2_coco.config
6、运行export_inference_graph.py将训练的模型参数固定
示例:
–pipeline_config_path=D:\Jupyter\TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10-master\SSD_2019_11_4\pipeline.config #配置文件位置
–trained_checkpoint_prefix=D:\Jupyter\TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10-master\SSD_2019_11_4\model.ckpt-1610 #训练模型位置
–output_directory=D:\Jupyter\TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10-master\SSD_2019_11_4\saved_model #保存路径
生成:
模型测试
直接修改使用object_detection_tutorial.ipynb即可