Target detection evaluation indicators Precision, Recall, mAP

Target detection evaluation indicators Precision, Recall, mAP

参考:
Object-Detection-Metrics
A Survey on Performance Metrics for Object-Detection Algorithms

1. Important definitions

1.1. Intersection over Union (IOU)

Intersection Over Union (IOU) is used to measure the coincidence rate of two boxes, and its calculation formula is as follows:
IOU = area ⁡ ( B p ∩ B gt ) area ⁡ ( B p ∪ B gt ) \mathrm{IOU}= \frac{\operatorname{area}\left(B_{p} \cap B_{gt}\right)}{\operatorname{area}\left(B_{p} \cup B_{gt}\right)}IOU=area(BpBgt)area(BpBgt)
where B p B_{p}Bpis the box predicted by the model, B gt B_{gt}BgtFor ground truth. Intuitive point:
insert image description here

During the experimental evaluation process, an IOU threshold will be set to judge B p B_{p}BpFor positive or negative samples, for example, setting the IOU threshold to 0.5 means:

  • IOU ≥ 0.5 : B p B_{p} Bpis a positive sample;
  • IOU < 0.5 : B p B_{p} Bpis a negative sample.

Thresholds are often set at 50%, 75% or 95%.

1.2.TP , FP , FN

  • True Positive (TP) : A correct detection, ie B p B_{p}Bpwith B gt B_{gt}BgtIOU ≥ threshold (initially set IOU threshold);
  • False Positive (FP): A wrong detection, representing the B p B_{p} predicted by the modelBpand the truth value B gt B_{gt}Bgt的IOU < threshold;
  • False Negative (FN) : represents the true value B gt B_{gt}BgtNot detected, that is, all B p B_{p} predicted by the modelBpThere is no connection with the B gt B_{gt}Bgtcoincident;

1.3.Precision (accuracy rate), Recall (recall rate)

  • Precision (accuracy rate): refers to the ratio of correct detection in all boxes predicted by the model on a picture, the expression
     Precision = TPTP + FP = TP all detections \text { Precision }=\frac{\mathrm{TP} }{\mathrm{TP}+\mathrm{FP}}=\frac{\mathrm{TP}}{\text { all detections }} Precision =TP+FPTP= all detections TP
  • Recall (recall rate): refers to the ratio of all ground truths that are correctly matched
     Recall = TPTP + FN = TP all ground truths \text { Recall }=\frac{\mathrm{TP}}{\mathrm{TP}+\ mathrm{FN}}=\frac{\mathrm{TP}}{\text { all ground truths }} Recall =TP+FNTP= all ground truths TP

2.Average Precision(AP)

AP is the average value of the Precision corresponding to all recalls between 0 and 1. From the formulas of Precision and Recall, it can be seen that as the model predicts more frames (all detections) on the picture, TP will have an upper limit, so the corresponding Precision will become smaller; when there are more all detections, it means that there are more More ground truth may be correctly matched, that is, TP will increase slightly, and Recall will become larger at this time. The reverse is also true, so we need the detector to maintain a high accuracy rate as the Recall increases (more and more ground truths are correctly matched).

Average Precision (AP) is used to calculate the area of ​​the Precision x Recall curve, as shown in the figure below, by interpolation.
insert image description here

There are examples in the above reference article, here is the analysis:

insert image description here
There are 7 images in total here, where the green bounding boxes represent 15 ground truths and the red bounding boxes represent 24 pre-boxes. Each predicted box pre-box contains a confidence. The following table shows each pre-box and the corresponding confidence, please note:

  • As long as the IOU between a pre-box and a ground truth is greater than the set threshold, it is marked as TP, otherwise it is FP.
  • On some pictures, if a ground truth overlaps with more than one pre-box, the pre-box with the largest IOU is TP, and the rest are FP.
    insert image description here

Because both Precision and Recall are calculated by FP and TP, the Precision x Recall curve is also drawn by calculating the cumulative TP or FP detection precision-recall value. First, we need to sort according to the credibility of the detection, and then calculate the Precision and Recall of each cumulative detection, as shown in the table below:
insert image description here
where Acc TP is the cumulative number of TPs. Calculate the current Precision and Recall based on the current Acc TP and Acc FP. Draw a line chart:
insert image description here
As mentioned above, the interpolation method is used to calculate AP. There are two interpolation methods here:

2.1 11-point interpolation

Calculation formula:
AP = 1 11 ∑ r ∈ { 0 , 0.1 , … , 1 } ρ interp ⁡ ( r ) \mathrm{AP}=\frac{1}{11} \sum_{r \in\{0,0.1 , \ldots, 1\}} \rho_{\operatorname{interp}(r)}AP=111r{ 0,0.1,,1}rinterp ( r )
Enclosure
ρ interp = max ⁡ r ˉ : r ~ ≥ r ρ ( r ~ ) \rho_{\text {interp }}=\max _{\bar{r}: \tilde{r} \geq r} \rho( \tilde{r})rinterp =rˉ:r~rmaxr (r~ )
The meaning of this formula is under 11 levels of recall, namelyr ∈ { 0 , 0.1 , … , 1 } r \in\{0,0.1, \ldots,1\}r{ 0,0.1,,1 } for interpolation. For example:

  • when r = 0 r=0r=For example ,ρ interp = max ⁡ r ˉ : r ~ ≥ 0 ρ ( r ~ ) \rho_{\text {interp }}=\max _{\bar{r}: \tilde{r} \geq 0} \ rho(\tilde{r})rinterp =maxrˉ:r~0r (r~ ), while at allr ~ ≥ 0 \tilde{r} \geq 0r~0 , can makeρ ( r ~ ) \rho(\tilde{r})r (r~ )the largestr ~ \tilde{r}r~ When it is equal to 0.0666, Precision=1 at this time.
  • when r = 0.1 r=0.1r=0.1时,ρ interp = max ⁡ r ˉ : r ~ ≥ 0.1 ρ ( r ~ ) \rho_{\text {interp }}=\max _{\bar{r}: \tilde{r} \geq 0.1} \ rho(\tilde{r})rinterp =maxrˉ:r~0.1r (r~ )for allr ~ ≥ 0.1 \tilde{r} \geq 0.1r~In the point of 0.1 , we can make ρ ( r ~ ) \rho(\tilde{r})r (r~ )the largestr ~ \tilde{r}r~ When it is equal to 0.1333, Precision=0.6666 at this time.
  • And so on, there is no r >= 0.5 r>=0.5r>=0.5 , so it is 0 afterwards, and the following formula is obtained:
    AP = 1 11 ∑ r ∈ { 0 , 0.1 , … , 1 } ρ interp ( r ) AP = 1 11 ( 1 + 0.6666 + 0.4285 + 0.4285 + 0.4285 + 0 + 0 + 0 + 0 + 0 + 0 ) AP = 26.84 % \begin{array}{l} AP=\frac{1}{11} \sum_{r \in\{0,0.1, \ldots, 1\ }} \rho_{\text {interp }(r)} \\ AP=\frac{1}{11}(1+0.6666+0.4285+0.4285+0.4285+0+0+0+0+0+0) \ \ AP=26.84 \% \end{array}AP=111r{ 0,0.1,,1}rinterp  ( r )AP=111(1+0.6666+0.4285+0.4285+0.4285+0+0+0+0+0+0)AP=26.84%

2.1 Full point interpolation

This picture is easy to understand, that is, to calculate the area:
insert image description here
insert image description here
Calculation formula:
AP = A 1 + A 2 + A 3 + A 4 A 1 = ( 0.0666 − 0 ) × 1 = 0.0666 A 2 = ( 0.1333 − 0.0666 ) × 0.6666 = 0.04446222 A 3 = ( 0.4 − 0.1333 ) × 0.4285 = 0.11428095 A 4 = ( 0.4666 − 0.4 ) × 0.3043 = 0.02026638 AP = 0.0666 + 0.04446222 + 0.114 28095 + 0.02026638 AP = 0.24560955 AP = 24.56 % \begin{array}{l} AP =A _1+A _2+A _3+A _4\\ A _1=(0.0666-0) \times 1=\mathbf{0 . 0 6 6 6} \\ A_ 2=(0.1333-0.0666) \times 0.6666= \mathbf{0 . 0 4 4 4 6 2 2 2} \\ A _3=(0.4-0.1333) \times 0.4285=\mathbf{0 . 1 1 4 2 8 0 9 5} \\ A _4=(0.4666- 0.4) \times 0.3043=\mathbf{0 . 0 2 0 2 6 6 3 8} \\ AP=0.0666+0.04446222+0.11428095+0.02026638 \\ AP=0.24560955 \\ AP=\mathbf{2 4 . 5 6} \ % \end{array}AP=A1+A2+A3+A4A1=(0.06660)×1=0.0666A2=(0.13330.0666)×0.6666=0.04446222A3=(0.40.1333)×0.4285=0.11428095A4=(0.46660.4)×0.3043=0.02026638AP=0.0666+0.04446222+0.11428095+0.02026638AP=0.24560955AP=24.56%

Guess you like

Origin blog.csdn.net/weixin_45453121/article/details/129737434