yolov5指标分析
IOU:(Intersection over union)
简述: 交集和并集的比值
将我们图片汽车的实际红色框记为A,算法的预测框记为B,交并比就是数学中A和B的交集A∩B跟A和B的并集的A∪B的面积之比,非常容易理解。IOU实际上衡量了两个边界框重叠地相对大小,预测框和真实框重叠越大,
说明你的算法预测效果比较好,及 IOU指标 越大越好。
代码实现
def IoU(bbox, prebox):
# bbox, prebox = [x,y,width,height]
# bbox,prebox左上角坐标
xmin1, ymin1 = int(bbox[0] - bbox[2] / 2.0), int(bbox[1] - bbox[3] / 2.0)
xmax1, ymax1 = int(bbox[0] + bbox[2] / 2.0), int(bbox[1] + bbox[3] / 2.0)
xmin2, ymin2 = int(prebox[0] - prebox[2] / 2.0), int(prebox[1] - prebox[3] / 2.0)
xmax2, ymax2 = int(prebox[0] + prebox[2] / 2.0), int(prebox[1] + prebox[3] / 2.0)
# 获取矩形框交集对应的左上角和右下角的坐标(intersection)
xx1 = np.max([xmin1, xmin2])
yy1 = np.max([ymin1, ymin2])
xx2 = np.min([xmax1, xmax2])
yy2 = np.min([ymax1, ymax2])
# 计算两个矩形框面积
bbox_area = (xmax1 - xmin1) * (ymax1 - ymin1)
prebox_area = (xmax2 - xmin2) * (ymax2 - ymin2)
inter_area = (np.max([0, xx2 - xx1])) * (np.max([0, yy2 - yy1])) # 计算交集面积
iou = inter_area / (bbox_area + prebox_area - inter_area + 1e-6) # 计算交并比
return iou
MAP指标
Precision
Precision = TP/(TP + FP)
Recall
Recall = TP/ (TP + FN)
- TP(True Postives): 分类器把正例正确的分类/预测为正例
- FN(False Negatives):分类器把正例错误的分类/预测为负例
- TN(True Negatives):分类器把负例正确的分类/预测为负例
- FP(False Postives):分类器把负例错误的分类/预测为正例
AP
- AP(Average Percision):AP为平均精度,指的是所有图片内的具体某一类的PR曲线下的面积
MAP
- 是指所有图片内的所有类别的AP的平均值。
案例
已知条件:班级总人数100人,其中男生80人,女生20人。
目标:找出所有的女生。
结果:从班级中选择了50人,其中20人是女生,还错误的把30名男生挑选出来了。
求:计算 TP,FP,FN,TN?
P:预测为正例 N:预测为负例
TP = 20
FP = 30
FN = 0
TN = 50
参考文章
本文作者:可可爱爱奇奇怪怪。。。
本文链接:https://www.cnblogs.com/ccsuf/p/16613746.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。