Non-Maximum Suppression
Follow non-maximum suppression through candidate scores and overlap comparisons, including class-aware and crowded-scene limitations.
Non-Maximum Suppression explained visually
Follow non-maximum suppression through candidate scores and overlap comparisons, including class-aware and crowded-scene limitations.
What you will learn
Locate objects, represent boxes, filter predictions, evaluate detections, and compare detector designs.
Recognize duplicate candidate boxes
One dog. Five boxes. If we counted every box, our detector would claim there were five dogs in the picture.
Many object detection systems can produce several overlapping predictions for the same object. A common way to reduce those duplicates is non-maximum suppression, often shortened to N M S.
The basic idea is to keep a strong prediction and suppress nearby predictions that probably describe the same object.
Apply greedy non-maximum suppression
Let’s say three dog boxes have confidence scores of zero point nine five, zero point eight, and zero point seven. We start with the highest-scoring box and keep it.
Next, we compare its overlap with the other boxes using intersection over union. If another box overlaps above our chosen suppression threshold, we remove that lower-scoring prediction.
We then take the highest-scoring box that remains and repeat the process. We continue until there are no candidates left to consider.
For a simple example, use an overlap threshold of zero point five. A lower-scoring box with an overlap of zero point eight is suppressed. A box with an overlap of zero point two is kept for further consideration. It may belong to a different dog.
Separate thresholds and class-aware behavior
Notice that we now have two different thresholds in the pipeline. The confidence threshold filters weak scores. The suppression threshold decides when overlapping boxes are treated as duplicates.
Many implementations run this process separately for each class. That helps avoid removing a person box just because it overlaps a bicycle box. Other implementations can suppress across classes, so the configuration matters.
Handle crowds and alternative detector designs
Non-maximum suppression is useful, but it is not perfect. Two real objects can overlap heavily in a crowded scene. An aggressive suppression setting may remove one of them.
Also, not every detector needs this exact step. Some detector designs are trained to produce a final set of detections with fewer duplicate predictions.
Next, we’ll move from cleaning up predictions to measuring the mistakes a detector makes.
Quick check: test your understanding
Which candidate is kept first in ordinary greedy NMS?
The highest-scoring remaining candidate.
What happens to a lower-scoring box with IoU 0.80 when the suppression threshold is 0.50?
It is suppressed when compared with the kept box.
Why can aggressive NMS fail in crowds?
Two real objects can overlap heavily, causing one valid detection to be removed.
Accessible referenceLesson 67 transcript318 words · Matches the published narration and captionsOpen transcript
One dog. Five boxes. If we counted every box, our detector would claim there were five dogs in the picture.
Many object detection systems can produce several overlapping predictions for the same object. A common way to reduce those duplicates is non-maximum suppression, often shortened to N M S.
The basic idea is to keep a strong prediction and suppress nearby predictions that probably describe the same object.
Let’s say three dog boxes have confidence scores of zero point nine five, zero point eight, and zero point seven. We start with the highest-scoring box and keep it.
Next, we compare its overlap with the other boxes using intersection over union. If another box overlaps above our chosen suppression threshold, we remove that lower-scoring prediction.
We then take the highest-scoring box that remains and repeat the process. We continue until there are no candidates left to consider.
For a simple example, use an overlap threshold of zero point five. A lower-scoring box with an overlap of zero point eight is suppressed. A box with an overlap of zero point two is kept for further consideration. It may belong to a different dog.
Notice that we now have two different thresholds in the pipeline. The confidence threshold filters weak scores. The suppression threshold decides when overlapping boxes are treated as duplicates.
Many implementations run this process separately for each class. That helps avoid removing a person box just because it overlaps a bicycle box. Other implementations can suppress across classes, so the configuration matters.
Non-maximum suppression is useful, but it is not perfect. Two real objects can overlap heavily in a crowded scene. An aggressive suppression setting may remove one of them.
Also, not every detector needs this exact step. Some detector designs are trained to produce a final set of detections with fewer duplicate predictions.
Next, we’ll move from cleaning up predictions to measuring the mistakes a detector makes.