Sub topic 13
Finding label errors from model mistakes
This chapter shows how to use a trained model's disagreements with your labels to find annotation mistakes. It assumes you can read COCO-style boxes, compute box IoU (intersection over union), and run a short Python script. It also assumes you know what the dataset splits do, as covered in the previous chapter. Review passes and audits catch many errors. Some mistakes survive them, and a model trained on the data often points straight at those.
Why model errors point to label errors
A model learns the pattern shared by most of your labels. When it confidently disagrees with one label, one of two things is true:
- The model is wrong. The object is hard, rare, or underrepresented.
- The label is wrong. The annotator missed the object, drew a loose box, or picked the wrong class.
The method is to rank the disagreements and have a human review the top of the list. The model never fixes labels on its own. It only decides where a reviewer looks first. A reviewer who checks 200 flagged images usually finds more errors than one who checks 200 random images.
Disagreements usually fall into four patterns:
| Pattern | What you see | Likely label problem |
|---|---|---|
| Confident prediction with no matching label | High score, IoU near 0 with every label | Missing label |
| Label with no matching prediction | Ground-truth box that no confident prediction overlaps | Spurious label, or a hard object |
| Overlap but weak IoU | Matching class, IoU between about 0.1 and 0.5 | Loose or shifted box |
| Overlap but different class | IoU high, predicted class differs from label | Wrong class, or a blurred taxonomy boundary |
The workflow
You cannot use the model's predictions on its own training images, and the reason matters. A network trained long enough memorises its training labels, mistakes included. On those images it will agree with the wrong label, and the error stays hidden. You need predictions from a model that did not train on the image being checked.
Two practical ways to get them:
- Cross-validation. Split the data into k folds (for example 5). Train k models, each on k−1 folds, and predict on the held-out fold. Every image then gets a prediction from a model that has never seen it.
- Held-out audit. Train on the training set and run the model on the validation and test sets. This is cheaper, but it covers only the images in those sets. Labels in the training set stay unchecked.
If images are near-duplicates, build the folds by group (by video, scene, or capture session), not at random. Otherwise a neighbouring frame leaks the label into the held-out prediction and the error is hidden again.
Matching predictions to labels
Use the same matching rules as detection evaluation. Process predictions from highest to lowest score. For each one, find the unmatched label with the highest IoU. Mark that label as used so one label cannot explain two predictions. Then classify the outcome by IoU thresholds.
The script below reuses box_iou from the agreement chapter. It takes one image's labels and predictions and returns a list of flags. Boxes use (x_min, y_min, x_max, y_max).
def box_iou(a, b):
"""Boxes in (x_min, y_min, x_max, y_max) format."""
ix1, iy1 = max(a[0], b[0]), max(a[1], b[1])
ix2, iy2 = min(a[2], b[2]), min(a[3], b[3])
inter = max(0, ix2 - ix1) * max(0, iy2 - iy1)
area_a = (a[2] - a[0]) * (a[3] - a[1])
area_b = (b[2] - b[0]) * (b[3] - b[1])
union = area_a + area_b - inter
return inter / union if union > 0 else 0.0
def triage_image(gt, preds, conf_thresh=0.8, iou_match=0.5, iou_loose=0.1):
"""gt: list of (label, box). preds: list of (label, score, box)."""
flags = []
used = set()
for p_label, score, p_box in sorted(preds, key=lambda p: -p[1]):
if score < conf_thresh:
continue
best_i, best_iou = None, 0.0
for i, (g_label, g_box) in enumerate(gt):
if i in used:
continue
v = box_iou(p_box, g_box)
if v > best_iou:
best_i, best_iou = i, v
if best_i is None or best_iou < iou_loose:
flags.append(("possible missing label", p_label, score, p_box))
elif best_iou < iou_match:
used.add(best_i)
flags.append(("possible loose box", p_label, score, p_box))
else:
used.add(best_i)
if gt[best_i][0] != p_label:
flags.append(("possible wrong class", p_label, score, p_box))
for i, (g_label, g_box) in enumerate(gt):
if i not in used:
flags.append(("possible spurious label", g_label, None, g_box))
return flags
gt = [
("car", (50, 40, 150, 90)),
("car", (300, 200, 400, 260)),
("person", (10, 10, 60, 120)),
]
preds = [
("car", 0.95, (52, 42, 148, 90)),
("truck", 0.90, (298, 198, 402, 262)),
("person", 0.92, (500, 300, 560, 380)),
]
for flag in triage_image(gt, preds):
print(flag)On this example the script prints three flags:
- The confident person at the lower right has no label, so it is a possible missing label.
- The second car label is matched by a confident truck prediction, so it is a possible wrong class.
- The person label at the upper left has no confident prediction, so it is a possible spurious label.
The first car matches cleanly and produces no flag.
Choosing the thresholds
conf_threshcontrols how much you trust the model. Start high (0.8 or more) so the review queue holds mostly real errors. Lower it later to catch subtler ones.iou_matchshould follow the box tolerance in your guidelines. If the guideline says boxes may be loose by a few pixels, 0.5 is a reasonable start. For tight boxes on small objects, try 0.6 or 0.7.iou_looseseparates "same object, bad box" from "different object." A value around 0.1 works as a starting point. Check a sample of flags and adjust.
Reading each pattern
Missing labels
This is usually the most common and most damaging error. An unlabelled object is a negative example for the model, which actively teaches it to ignore that object. Look for clusters. If many missing labels share one situation, such as distant pedestrians or objects partly hidden by another object, the cause is probably a guideline gap, not individual slips. Fix the guideline first, then relabel.
Spurious labels and hard objects
A label with no matching prediction is ambiguous. It may be a box around nothing, or a real object the model has not learned yet. Sort these by how many models or folds missed them. If every fold misses a label, a person should look at it. Very small, heavily truncated, or blurred objects often land here and may be legitimate. Compare them to your occlusion and truncation rules before deleting anything.
Loose or shifted boxes
Run these through the checks from the quality-control chapter as well. Flagged boxes with IoU between 0.1 and 0.5 often come from one annotator or one tool setting, such as a systematic offset. Group the flags by annotator and by image source. A strong skew toward one group means you should retrain that annotator or fix the tool, not edit each box.
Wrong class
Count the pairs of (labelled class, predicted class) over the whole dataset. A few isolated flags are slips. A large count for one pair, for example van labelled and truck predicted, points at a taxonomy problem. The classes may overlap, or the guideline may not give a rule for the boundary.
from collections import Counter
def confusion_pairs(flag_records):
"""flag_records: iterable of (gt_class, predicted_class) for wrong-class flags."""
return Counter(flag_records).most_common()
records = [
("van", "truck"), ("van", "truck"), ("van", "truck"),
("car", "truck"), ("bus", "truck"), ("van", "car"),
]
for (labelled, predicted), count in confusion_pairs(records):
print(f"{labelled} -> {predicted}: {count}")The pair van -> truck appears three times and tops the list. That is your cue to read the guideline entries for both classes and add a deciding rule, such as "vehicles with an enclosed cargo area behind the cab are van only if under a stated size."
Ranking the review queue
Reviewer time is the scarce resource, so order the queue. A simple score is the model's confidence in the disagreement, with ties broken by how many folds or model checkpoints agree. For segmentation, replace box IoU with mask IoU and apply the same logic. Pixel-level flags are noisy, so also look at whole-object disagreement, for example a predicted mask with no overlapping label mask.
Review in batches of about 50 to 100 flags. Record for each one whether it was a real label error, a model error, or a guideline gap. The ratio is the most informative output of this process:
- If most flags are real label errors, your dataset has a quality problem worth another review pass.
- If most flags are model errors, the labels are probably fine and the model needs more data or capacity. Stop reviewing.
- If many flags are guideline gaps, update the guideline and relabel the affected class.
Limits and failure modes
- Systematic errors hide. If every annotator makes the same mistake, the model learns it and agrees with it. Model-based triage finds random errors, not shared misconceptions. Guideline review and spot audits cover that gap.
- Class imbalance. Rare classes have low model confidence even when the labels are right, so you will see many false flags. Lower the confidence bar for them cautiously and expect more model errors in the queue.
- Retrain after fixing. Once you correct labels, the old predictions are out of date. Retrain, rerun the out-of-fold step, and see whether the flag rate fell. A drop confirms the fixes helped.
- Test set contamination. If you fix test labels based on model disagreement, the test score will rise partly because labels now match the model. Keep a record of what changed, and report scores before and after the fix.
- Duplicates. Near-duplicate images flagged in one fold usually appear in others. Group them so reviewers fix the pattern once.
Exercise
Your model was trained on all 1,000 labelled images. You run it on those same 1,000 images and find very few disagreements with the labels. Does this mean the labels are clean? What should you do instead?
Show answer
No. The model has seen these images and can memorise their labels, including wrong ones, so it agrees with them. Use out-of-fold predictions: split the images into k folds (grouped by scene or video so near-duplicates stay together), train on k−1 folds, and predict on the held-out fold. Then run the matching step on those predictions.
Exercise
A review of 100 "possible wrong class" flags shows 70 cases where the label was van and the model predicted truck, and reviewers disagree with each other on about half of them. What is the most likely cause, and what is the right fix?
Show answer
The most likely cause is a taxonomy or guideline problem. The boundary between van and truck is not defined clearly enough for people to apply it consistently. The fix is to add an explicit deciding rule with example images, or to merge the classes if the distinction does not matter for the task. Then relabel the affected images. Editing the 70 boxes one by one without changing the guideline would let the same disagreement return.