【darknet-YOLO】目标检测中的几个阈值nms-confidence nms-IoU,map-confidence, map-IoU
这里依据darknet来分析,但是适用所有的目标检测算法。
1. nms的confidence thresh
训练好模型执行检测,会得到多组检测结果,每组包括一个bounding box四个坐标相关值和每个bounding box所对应类别的置信度。
首先这里设定一个confidence阈值,低于阈值的bounding box直接去掉(置0)。
darknet中这个thresh是0。
2. nms的IoU thresh
然后剩下的bounding box中选出每个类别confidence最高的bounding box,根据nms算法再去掉一些bounding box。
nms算法的理论请参考链接:【目标检测】NMS(Non-maximum suppression,非极大值抑制)算法。
举例来说。
对每一个类,依次计算剩下的bounding box和选出来的confidence最高的bounding box计算IoU。
计算出的IoU大于nms-IoU阈值的bounding box去掉(置0)。
darknet中计算recall时thresh是0.4,计算map和test_detector时是0.45。
3. map的confidence thresh
经过nms之后得到的一系列bounding box和类别,我们也并不会认为预测得到的结果都是正确的。
因此还会设定一个confidence thresh,大于thresh的bounding box类别是positive正例,反之则是negative负例。
4. map的IoU thresh
经过第3步的阈值过滤之后,才会设定一个map的IoU thresh,计算与groundtruth的IoU,大于thresh的是true positive(真正例,TP),反之则是false positive(假正例,FP),从而计算出AP和mAP。
通过不断选定confience阈值可以画出PR曲线。