Pedestrain
使用darknet训练:
1. Inria
-
创建 yolo-inria.cfg
从cfg/yolo-voc.2.0.cfg拷贝一份,修改batch=64, subdivisions=8, classes=1, 修改最后一个卷积层为filter=30。
cp cfg/yolo-voc.2.0.cfg cfg/yolo-inria.cfg
-
创建data/inria.names
里面只有一行:person
-
为每个图片创建label文件,形式如下:
每个图片对应一个label文件,一个行人对应一行,object-class全为0。文件分别放在/home/guru_ge/dataset/INRIAPerson/Train/labels目录和/home/guru_ge/dataset/INRIAPerson/Test/labels目录。
<object-class> <x> <y> <width> <height>
-
创建train.txt, test.txt
所有训练图片的路径,每行一张图片,位置在/home/guru_ge/dataset/INRIAPerson/。
data/obj/img1.jpg
data/obj/img2.jpg
data/obj/img3.jpg -
创建data/inria.data
修改train.txt, test.txt位置:
classes= 1 train = /home/guru_ge/dataset/INRIAPerson/train.txt valid = /home/guru_ge/dataset/INRIAPerson/test.txt names = data/obj.names backup = backup/
-
下载在ImageNet上预训练的darknet19模型
wget http://pjreddie.com/media/files/darknet19_448.conv.23
-
开始训练
./darknet detector train data/inria.data cfg/yolo-inria.cfg darknet19_448.conv.23 -gpus 0
结果
在INRIA测试集上评测结果:
./darknet detector map cfg/inria.data cfg/yolo-inria.cfg backup/yolo-inria.backup -gpus 0
class_id = 0, name = person, ap = 88.85 %
for thresh = 0.24, precision = 0.95, recall = 0.86, F1-score = 0.90
for thresh = 0.24, TP = 509, FP = 29, FN = 80, average IoU = 76.81 %mean average precision (mAP) = 0.888518, or 88.85 %
Total Detection Time: 4.000000 Seconds
测试图片:
./darknet detector test cfg/inria.data cfg/yolo-inria.cfg backup/yolo-inria.backup -gpus 0
跑另外一个视频:
./darknet detector demo cfg/inria.data cfg/yolo-inria.cfg backup/yolo-inria.backup MOT16-06.mp4 -gpus 0
效果:
大小:
416 x 416
速度:
CPU FPS: 0.2
GPU FPS: 90
问题:
小目标检测不到
2. caltech
训练:
./darknet detector train cfg/caltech.data cfg/yolo-caltech.cfg darknet19_448.conv.23 -gpus 0 -dont_show
每5帧提取一张,训练集45651张图片,测试集4406张图片。batch_size为64,迭代3万次左右开始收敛:
评估:
./darknet detector map cfg/caltech.data cfg/yolo-caltech.cfg backup_caltech/yolo-caltech_40000.weights -gpus 0
detections_count = 24968, unique_truth_count = 6465
class_id = 0, name = person, 8 ap = 22.66 %
for thresh = 0.24, precision = 0.41, recall = 0.22, F1-score = 0.29
for thresh = 0.24, TP = 1431, FP = 2053, FN = 5034, average IoU = 27.87 %mean average precision (mAP) = 0.226584, or 22.66 %
Total Detection Time: 137.000000 Seconds
问题:
从map上看表现很差,只有22.66,这可能是因为这个数据集人太小,并且标注中还包含了一些被遮挡的目标,干扰了检测结果。
我们还测试了使用inria数据集训练的模型在caltech上的结果,表现还要更差:
detections_count = 17643, unique_truth_count = 6465
class_id = 0, name = person, 3 ap = 9.09 %
for thresh = 0.24, precision = 0.48, recall = 0.05, F1-score = 0.09
for thresh = 0.24, TP = 315, FP = 340, FN = 6150, average IoU = 35.57 %mean average precision (mAP) = 0.090909, or 9.09 %
Total Detection Time: 46.000000 Seconds
./darknet detector demo cfg/caltech.data cfg/yolo-caltech.cfg yolo-caltech_30000.weights
使用caltech训练结果,小目标的检测更准确了,但也存在了误检的问题,这可能是标注中还包含了一些被遮挡的行人,导致训练的模型将这些遮挡物也认为是行人,出现了误检。