Object Detection & Segmentation
Q: How do object detectors work? How are they evaluated?
- Two-stage (Faster R-CNN): a region proposal network suggests boxes, then RoI Align crops features and a head classifies + refines each box. Accurate, slower.
- One-stage (YOLO, SSD, RetinaNet): predict class scores and box offsets densely over a grid of anchors in one pass; RetinaNet's focal loss fixes the extreme foreground/background imbalance. Fast, the default for real time.
- Anchor-free (FCOS, CenterNet) predict centers/distances directly; DETR treats detection as set prediction with a transformer and Hungarian matching between predictions and ground truth — no anchors, no NMS.
- Post-processing: score threshold + non-maximum suppression (see ML Coding).
- Metrics: IoU decides a true positive; AP = area under the precision–recall curve per class; mAP averages classes; COCO averages mAP over IoU thresholds 0.5:0.95.
- Segmentation: semantic (a class per pixel: U-Net encoder–decoder with skip connections, DeepLab with atrous convolutions), instance (Mask R-CNN adds a mask head), panoptic (both); SAM segments anything from point/box prompts.
- Practical: small objects (feature pyramids, higher resolution), class imbalance, label noise in boxes, deployment latency (quantization, smaller backbones).