IOU (Intersection Over Union, 交并比)
IOU指真实框和预测框之间交集和并集的比,假设这里有真实框 B g t B_{gt} Bgt和预测框 B p B_p Bp,那么 IOU计算公式如下:
I O U = a r e a ( B p ∩ B g t ) a r e a ( B p ∪ B g t ) IOU=\frac{area(B_p\cap B_{gt})}{area(B_p\cup B_{gt})} IOU=area(Bp∪Bgt)area(Bp∩Bgt)

有了IOU的计算公式,我们就可以来计算 TP、FP、FN、TN
这里会用到threshold交并比的阈值,通常取50%、75%、95%

- True Positive(TP): 一个目标框被正确检测出来, I O U ≥ t h r e s h o l d IOU \ge threshold IOU≥threshold
- False Positive(FP): 预测框预测错误, I O U < t h r e s h o l d IOU < threshold IOU<threshold
- False Negative(FN): 一个目标框没有被预测出来
- True Negative(TN): 在这里不适用。
Precision精确率
precision指正确检测出来的目标框数量占所有预测目标框数量的比例。
P r e c i s i o n = T P T P + F P = T P a l l _ d e t e c t i o n s Precision = \frac{TP}{TP+FP}=\frac{TP}{all\_detections} Precision=TP+FPTP=all_detectionsTP
Recall召回率
recall指正确检测出来的目标框数量占所有真实目标框数量的比例。
R e c a l l = T P T P + F N = T P a l l _ g r o u n d _ t r u t h s Recall = \frac{TP}{TP+FN}=\frac{TP}{all\_ground\_truths} Recall=TP+FNTP=all_ground_truthsTP
Precision x Recall curve, PR曲线
以精确率为y轴,以召回率为x轴,我们就得到了PR曲线。仍然从精确率和召回率的定义可以理解,精确率越高,召回率越高,我们的模型和算法就越高效。也就是画出来的PR曲线越靠近右上越好。
Average Precision,AP
PR曲线下面的面积。假设一共有N中recall的取值,计算公式如下:
A P = ∑ n = 1 N ( r n + 1 − r n ) ρ i n t e r p ( r n + 1 ) ρ i n t e r p ( r n + 1 ) = m a x r ^ = r n + 1 ρ ( r ^ ) AP=\sum_{n=1}^{N}(r_{n+1}-r_n)\rho_{interp}(r_{n+1})\\ \rho_{interp}(r_{n+1})= max_{\hat r=r_{n+1}} \rho(\hat r) AP=n=1∑N(rn+1−rn)ρinterp(rn+1)ρ