目录
第二章 object_detection开源框架使用案例入门
第四章 基于tensorflow-cpu的object_detection开源框架模型训练
第五章 基于GPU服务器的object_detection开源框架模型训练
第七章 yolo开源框架安装及使用
yolo框架主要是做实时目标检测的,它的模型分基础和tiny两种类型,可以让用户在速度和检测效果之间进行平衡选择。实时摄像头目标检测需要cuda。
7.1 yolov3
7.1.1 yolov3模型
在目录:/home/users/chenzhuo下
安装Darknet
# git clone https://github.com/pjreddie/darknet
# cd darknet
# make
下载预训练模型权重文件
# wget https://pjreddie.com/media/files/yolov3.weights
运行探测器进行检测,更改检测阈值
# ./darknet detect cfg/yolov3.cfg yolov3.weights /home/users/py3_project/models/research/object_detection/test_images/01.jpg -thresh 0.25
检测时间:82s
该图片被保存在当前目录下的predictions.png中。
7.1.2 yolov3-tiny模型
下载预训练模型权重文件
# wget https://pjreddie.com/media/files/yolov3-tiny.weights
运行探测器进行检测
# ./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights /home/users/py3_project/models/research/object_detection/test_images/01.jpg
检测时间:8s
7.2 yolov2
7.2.1 yolov2模型
下载预训练模型权重文件
# wget https://pjreddie.com/media/files/yolov2.weights
运行探测器进行检测
# ./darknet detect cfg/yolov2.cfg yolov2.weights /home/users/py3_project/models/research/object_detection/test_images/01.jpg
检测时间:37s
7.2.2 yolov2-tiny模型
下载预训练模型权重文件
# wget https://pjreddie.com/media/files/yolov2-tiny-voc.weights
运行探测器进行检测
# ./darknet detector test cfg/voc.data cfg/yolov2-tiny-voc.cfg yolov2-tiny-voc.weights /home/users/py3_project/models/research/object_detection/test_images/01.jpg
检测时间:4s
7.3 yolov1
7.3.1 yolov1模型
下载预训练模型权重文件
# wget https://pjreddie.com/media/files/yolov1.weights
运行探测器进行检测
# ./darknet yolo test cfg/yolov1.cfg yolov1.weights /home/users/py3_project/models/research/object_detection/test_images/01.jpg
检测时间:18s
7.3.2 yolov1-tiny模型
下载预训练模型权重文件
# wget https://pjreddie.com/media/files/yolov1/tiny-yolov1.weights
运行探测器进行检测
# ./darknet yolo test cfg/yolov1-tiny.cfg tiny-yolov1.weights /home/users/py3_project/models/research/object_detection/test_images/01.jpg
检测时间:2s
7.4 使用yolov3训练自己的模型
7.4.1 下载数据集
目录/home/users/chenzhuo/darknet/scripts下,
# wget https://pjreddie.com/media/files/VOCtrainval_11-May-2012.tar
# wget https://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar
# wget https://pjreddie.com/media/files/VOCtest_06-Nov-2007.tar
# tar xf VOCtrainval_11-May-2012.tar
# tar xf VOCtrainval_06-Nov-2007.tar
# tar xf VOCtest_06-Nov-2007.tar
7.4.2 生成数据集标签
# wget https://pjreddie.com/media/files/voc_label.py
# python3 voc_label.py
# cat 2007_train.txt 2007_val.txt 2012_*.txt > train.txt
7.4.3 修改数据cfg
修改cfg/voc.data配置文件,将path-to-voc指向VOC数据的目录
1 classes= 20
2 train = /train.txt
3 valid = 2007_test.txt
4 names = data/voc.names
5 backup = backup
7.4.4 下载预训练卷积权重
# cd /home/users/chenzhuo/darknet
# wget https://pjreddie.com/media/files/darknet53.conv.74
7.4.5 训练模型
# ./darknet detector train cfg/voc.data cfg/yolov3-voc.cfg darknet53.conv.74
7.4.6 图片测试
# ./darknet detector test cfg/yolov3-voc.cfg backup/yolov3-voc_10000.weights /home/users/py3_project/models/research/object_detection/test_images/01.jpg