Sub topic 11
Quality Control: Review Passes, Audits, and Validation Scripts
Assume you know Python lists and dictionaries, JSON, image width and height, and the difference between a training and validation set. This chapter uses those ideas to build a repeatable quality-control process for detection and segmentation labels.
Why quality control matters
A model learns from the labels it receives. A box that is shifted, a missing object, or an inconsistent class name becomes part of the training signal. A few mistakes may be harmless, but systematic mistakes can make the model fail on important cases.
Quality control should check three different things:
- Validity: Is the annotation structurally legal?
- Consistency: Did different annotators apply the same rules?
- Usefulness: Does the label describe what the model must learn?
A valid annotation can still be poor. For example, a box may be inside the image but include too much background.
A review workflow
Use several review passes instead of asking one reviewer to judge everything at once.
- The annotator labels the image using the written guidelines.
- An automated script checks file structure, class IDs, coordinates, and polygon shape.
- A reviewer checks a sample of images for missed objects, incorrect classes, and inaccurate boundaries.
- A second annotator independently labels a subset.
- The team measures agreement and discusses disagreements.
- Model predictions are reviewed after training. Repeated errors may reveal unclear or incorrect labels.
A first review pass should focus on obvious problems. A later audit should focus on difficult cases, such as heavy occlusion, truncation at an image edge, reflections, and objects that are too small to identify confidently.
Automated validation
Validation scripts catch errors that are tedious to find visually. For a box stored as [x, y, width, height], check that width and height are positive and that the box stays within the image.
The following script validates a small COCO-style annotation structure. It reports unknown image and category references, invalid boxes, and boxes outside image boundaries.
def validate_annotations(data):
images = {image["id"]: image for image in data["images"]}
categories = {category["id"] for category in data["categories"]}
problems = []
for annotation in data["annotations"]:
annotation_id = annotation["id"]
image_id = annotation["image_id"]
if image_id not in images:
problems.append(
f"annotation {annotation_id}: unknown image_id {image_id}"
)
continue
if annotation["category_id"] not in categories:
problems.append(
f"annotation {annotation_id}: unknown category_id"
)
x, y, width, height = annotation["bbox"]
image = images[image_id]
if width <= 0 or height <= 0:
problems.append(
f"annotation {annotation_id}: non-positive box size"
)
if x < 0 or y < 0 or x + width > image["width"] or y + height > image["height"]:
problems.append(
f"annotation {annotation_id}: box outside image"
)
return problems
data = {
"images": [{"id": 1, "width": 640, "height": 480}],
"categories": [{"id": 1, "name": "car"}],
"annotations": [
{
"id": 1,
"image_id": 1,
"category_id": 1,
"bbox": [600, 40, 100, 50],
}
],
}
for problem in validate_annotations(data):
print(problem)Also check that every image has a readable file, every class name belongs to the taxonomy, polygon coordinates are numeric, and segmentation polygons have enough points to form a shape. If a polygon is converted to a mask, compare its recorded area with the number of foreground pixels. A large difference can indicate a conversion or coordinate error.
Measuring agreement
For boxes, intersection over union, or IoU, measures overlap between two boxes:
IoU = intersection area / union area
An IoU of 1 means identical boxes. An IoU of 0 means no overlap. Choose a threshold that matches the task. A strict threshold may be appropriate for small objects, while a lower threshold may be reasonable when boundaries are inherently uncertain.
Agreement is more than one score. Record:
- Class agreement
- Whether both annotators found the object
- Box or mask IoU
- Differences in occlusion and truncation labels
- The reasons for disagreements
Use disagreements to improve the guideline. If annotators repeatedly disagree about partially hidden objects, add an explicit example and rule rather than treating each disagreement as an individual mistake.
Audits, splits, and model errors
Keep an audit log with the image ID, issue type, reviewer, decision, and guideline version. Sample both ordinary images and high-risk groups. For example, audit images with small objects, crowded scenes, rare classes, and labels produced by a pre-labeling model.
Prevent leakage when creating dataset splits. Near-duplicate frames from one video, or several crops of the same original image, must stay in the same split. Otherwise, validation results may look strong because the model has already seen nearly identical content during training.
After training, inspect false positives and false negatives. A repeated false negative may indicate an object class that is too broad, a missing label, or a rule that excludes useful examples. Treat model error analysis as another quality-control signal, not as proof that the model alone is wrong.
Exercise
A box passes all coordinate checks, but two annotators give it IoUs of 0.32 and 0.91 on different images. What should you investigate first?
Show answer
Investigate the image groups and annotation rules. The variation may come from object size, occlusion, truncation, or ambiguous box boundaries. Review examples and update the guideline if the disagreement is systematic.