Sub topic 12
Evaluating Instances with Mask AP
Assume you know binary masks, object classes, confidence scores, intersection over union (IoU), and precision and recall. This chapter explains how to evaluate instance segmentation, where each detected object needs both the correct class and the correct pixels.
What mask AP measures
A model produces a list of predictions for each image. Each prediction contains a class, a confidence score, and a mask. The dataset provides ground-truth objects with classes and masks.
Evaluation sorts predictions from highest to lowest confidence. For each prediction, the evaluator finds the unmatched ground-truth object of the same class with the highest mask IoU.
- If the IoU reaches the chosen threshold, the prediction is a true positive.
- If no unmatched ground-truth mask reaches the threshold, it is a false positive.
- A ground-truth object with no matched prediction is a false negative.
Each ground-truth object can match at most one prediction. This prevents several predictions from receiving credit for the same object.
From precision and recall to AP
As the score cutoff moves down the sorted list, the evaluator records precision and recall. The precision-recall curve shows the trade-off between finding more objects and accepting more incorrect predictions.
Average precision (AP) summarizes the area under this curve. AP50 uses a mask IoU threshold of 0.50, while AP75 requires 0.75 IoU. A high AP50 but much lower AP75 often means that the model finds the right objects but produces imprecise boundaries.
COCO-style mask AP averages AP over thresholds from 0.50 through 0.95 in steps of 0.05. It also averages across classes and images. This makes the score stricter than a single-threshold result.
| Metric | What it tests |
|---|---|
| AP50 | Detection and reasonably overlapping masks |
| AP75 | More accurate mask boundaries |
| AP | Average over multiple IoU thresholds |
| AP small, medium, large | Performance by object size |
Mask AP differs from bounding-box AP because matching uses mask overlap, not rectangle overlap. Two boxes can overlap well while their object boundaries differ substantially.
Common errors
- Matching by score alone: A high-confidence prediction still fails if its class or mask IoU is wrong.
- Allowing duplicate matches: Only the first suitable prediction may claim a ground-truth instance.
- Using box IoU: This measures detection boxes, not segmentation quality.
- Ignoring score calibration: A poor ranking lowers AP even when the final thresholded predictions look reasonable.
- Mixing image scales: Predictions and ground-truth masks must use the same pixel coordinate frame.
- Reporting only AP50: Include stricter thresholds and object-size groups to reveal boundary and small-object failures.
Exercise
A prediction has the correct class and mask IoU 0.72 with an unmatched ground-truth mask. Is it a true positive at IoU thresholds 0.50 and 0.75?
Show answer
It is a true positive at 0.50 and a false positive at 0.75. The ground-truth instance remains unmatched for the 0.75 evaluation.