Loading

COCO 目标检测 mAP AR等指标的计算

AR

Average Precision(AP)

used for Object Detection

mAP = mean AP(per class)

https://kharshit.github.io/blog/2019/09/20/evaluation-metrics-for-object-detection-and-segmentation

如何快速计算IoU

这里不太确定是不是要计算所有Ground Truth以及Bounding Boxes的IoU

怎样的检测结果算是正确的

没有绝对正确,\(IoU = 1.0\)的情况

通过设定阈值,将足够接近的例子认定TP

这样的认定方法对不同准确率的方法是不公平的
mAP是对AP的推广,通过取不同的阈值计算衡量总体性能

怎样计算AP

Average Precision (AP)的精确定义是 Area Under Precision-Recall Curve

\[AP = \int_{0}^{1}\text{PR}(r)\text{d}r \]

Precision-Recall Curve

注意,在实际工程当中,没有真实的连续曲线,需要指定离散的recall

比如COCO采用的就是[0:.01:1],101个 recall 作为阈值,并按照下列公式近似

\[\text{AP} = \frac{1}{101}(P_{0}+P_{0.01}+P_{0.02} + \dots + P_{1}) \]

\(P_{\text{recall}}\)代表特定recall(即特定IoU threshold)下的准确率


如何计算TP,FN

在目标检测中,检测器得到的结果要么是True Positive,要么是False Positive


P1是对应ground truth A的TP
P2是FN

假设提供的有标签数据中,共有\(K\)个 ground truth标注框,在\(N\)帧中共检出\(M\)个框

对于任意一个检测器的输出,都需要进行考察

  • 首先,检测器的框一定包含cls confidence,一般是一个\(C\)(类别个数)维的向量。对每一个检测框,都为之计算一个IOU分数

Confidence score is the probability that an anchor box contains an object. It is usually predicted by a classifier.

采用如下伪代码计算

for each bbox that has a confidence score > threshold:

  among the ground-truths

  choose one that belongs to the same class and has the highest IoU with the bbox

  if no ground-truth can be chosen or IoU < threshold (e.g., 0.5):
    the detection bbox is a false positive
  else:
    the detection bbox is a true positive

得到如下表格

  • 将表格按照cls confidence降序排序

\[\text{Recall} = \text{Recall}(conf) \]

召回率会随着cls confidence的增加而单调递减(因为有效的检测框数单调减少)

  • 以此排序便可以得到Precison-Recall Curve

图片来源

AP(IOT_thresh,class)

AP是针对特定类的,在特定精度要求(IoU threshold)下的性能指标

\(\text{AP} \Rightarrow\text{AP}_{\text{cls}}^{\text{conf\_thresh}}(\text{Model})\)

通常所说的AP实际上是\(AP_{\text{cls}}^{\text{IoU} = 0.5}\)

AP的计算需要两个步骤

  1. 绘制PRC曲线

不断调整class confidence threshold,计算recall 和precision

blog

  1. 计算曲线下面积

在实际工程中需要采用离散求和方法代替积分

mAP = average AP over classes

mAP是通过类间平均,衡量检测算法性能的指标

AP的应用

PASCAL

详见

https://kharshit.github.io/blog/2019/09/20/evaluation-metrics-for-object-detection-and-segmentation


插值准确度(interpolated precision)

COCO

in COCO, mAP is also referred to as AP

在COCO当中采用

\[mAP_{\text{COCO}} = \frac{mAP_{0.50} + mAP_{0.55} + ... + mAP_{0.95}}{10} \]

\(AP@[.5:.05:.95].\)的含义就是以range(0.5,0.95,step = 0.05)的不同IoU threshold情况下,计算的AP的平均值

COCO有不同的衡量标准

posted @ 2022-09-03 22:24  ZXYFrank  阅读(1292)  评论(0编辑  收藏  举报