Computer Vision
IoU & Non-Max Suppression
How object detectors clean up their messy predictions by mathematically grouping overlapping boxes and keeping only the most confident one.
Stage 1 of 3: Bounding Boxes
IoU is 0.07
- Box 1 (Confidence 0.9)
- Box 2 (Confidence 0.7)
An object detector proposes multiple boxes with confidence scores. Often, it detects the same object multiple times.
Check your understanding
2 questions in the bank. Each attempt draws a fresh set in a fresh order, so a second go is a real second go.
Calculate the overlap between bounding boxes and use it to filter out duplicate detections of the same object using Non-Max Suppression.
When an object detector processes an image, it doesn't just find an object once. It typically proposes hundreds or thousands of bounding boxes, and often, multiple high-confidence boxes cluster around a single real object.
Intersection over Union (IoU) is the mathematical tool we use to measure how much two boxes overlap. By dividing the area where they intersect by the total area they cover, we get a score from 0 (no overlap) to 1 (perfect overlap).
Non-Max Suppression (NMS) uses IoU to clean up the predictions. It sorts all the proposed boxes by confidence. It takes the most confident box as a true detection, and then suppresses any other box that has an IoU higher than a given threshold with it. By repeating this process, it keeps only the single best box for each object in the scene.
Reference
- IoU
- Intersection over Union. A score from 0 to 1 measuring overlap.
- NMS
- Non-Max Suppression. The algorithm that removes redundant overlapping boxes.
Break it on purpose
Setting the NMS threshold too low merges separate objects into one, missing detections. Setting it too high leaves duplicate boxes around a single object.