Sub topic 18
Common Pitfalls and Practical Checks
Assume you know basic Python and NumPy, convolutional neural networks, object detection, and gradient-based training. Segmentation systems often fail because of data or evaluation mistakes rather than because the model is too small. Check the full pipeline before changing the architecture.
Verify label meaning and shape
A semantic target is usually a two-dimensional integer label map with shape (H, W). Each integer must map to the same class in training, validation, and evaluation. A value such as 255 often means “ignore,” not a real class.
An instance target needs more information. Pixels must identify both a class and an object instance. Two cars may share the class label car, but their instance IDs must differ.
| Representation | Typical shape | Main check |
|---|---|---|
| Semantic label map | `(H, W)` | Every value is a valid class or ignore value |
| Binary mask stack | `(N, H, W)` | Each mask belongs to the correct object |
| Panoptic ID map | `(H, W)` | IDs do not overlap and encode the intended class |
Before training, inspect several images beside their labels. Print the unique label values. Confirm that the image and label have identical height and width.
Preserve masks during preprocessing
Image resizing may use bilinear interpolation because it produces smooth colors. Masks require nearest-neighbor interpolation. Other interpolation methods create fractional or invented class IDs.
Apply geometric augmentation identically to the image, semantic map, boxes, and instance masks. A horizontal flip applied to only the image produces incorrect supervision. Crop operations must also update boxes and remove or clip objects that leave the crop.
Check splits and annotations
Do not place near-duplicate frames from the same video in both training and validation sets. This creates leakage and makes the validation score look better than performance on new scenes.
Look for these annotation errors:
- Missing objects or incomplete boundaries.
- Overlapping instance masks that should be separate.
- A class mapped to different IDs in different files.
- Tiny objects removed by a preprocessing threshold.
- Crowd or uncertain regions counted as ordinary background.
Keep a small, manually reviewed validation subset. It provides a stable reference when you change code.
Validate metrics and inference
For IoU, verify the confusion-matrix convention. If rows represent ground truth and columns represent predictions, the diagonal contains true positives. Do not average absent classes as zero unless that is the chosen benchmark rule. Many evaluations exclude classes absent from both prediction and target.
Instance mask AP depends on confidence thresholds, duplicate detections, and mask IoU matching. Panoptic quality also depends on matching predicted and true segments at a specified IoU threshold. Confirm the benchmark’s rules before comparing scores.
A useful end-to-end check is to overfit one or two training images. A correctly connected pipeline should drive training error low and reproduce their masks closely. If it cannot, inspect label values, tensor shapes, resizing, and loss reduction before tuning hyperparameters.
Exercise
A validation IoU suddenly falls after adding random resizing. What should you check first?
Show answer
Check that the label map uses nearest-neighbor resizing and that the resized image and label still have matching dimensions and aligned pixels.