Course contentsShow
← Machine Learning and Deep Learning
Lesson 974 of 3,53822. Computer Vision TasksFree lesson

Post-Processing: NMS Variants and Soft-NMS

Techniques to filter overlapping detections including confidence thresholding and soft non-maximum suppression.

Post-Processing: NMS Variants and Soft-NMS

What You'll Learn

You'll understand how to improve detection results beyond basic NMS by using soft-scoring methods that preserve more valid detections while still removing duplicates.

The Problem with Standard NMS

You've already learned about Non-Maximum Suppression (NMS) in lesson 954. Standard NMS uses a binary decision: if two bounding boxes overlap beyond a threshold (typically IoU > 0.5), it completely eliminates the lower-confidence box. This works well, but it's aggressive—sometimes it discards valid detections, especially when objects are truly close together or partially occluding each other.

Soft-NMS: A Gentler Approach

Soft-NMS doesn't completely eliminate overlapping boxes. Instead, it reduces their confidence scores based on how much they overlap with higher-scoring boxes. Think of it like this: standard NMS is a light switch (on/off), while Soft-NMS is a dimmer (gradual adjustment).

The key insight: if a box overlaps significantly with a better detection, it's probably a duplicate—but maybe not entirely. Rather than delete it, reduce its confidence proportionally. If it's still confident enough after penalty, keep it around.

How Soft-NMS Works

  1. Start with the highest-confidence detection (just like NMS)
  2. For all remaining boxes that overlap with it:
    • Instead of deleting them, decay their scores based on IoU
    • Higher overlap → larger penalty
  3. Move to the next highest-confidence box and repeat
  4. Finally, apply a confidence threshold to filter low-scoring boxes

Common decay functions:

  • Linear: score = score × (1 - IoU)
  • Gaussian: score = score × exp(-(IoU² / σ))

When to Use Soft-NMS

Soft-NMS particularly helps when detecting crowded scenes or overlapping objects where standard NMS might be too harsh. It typically improves mAP by 1-2% with minimal computational overhead.

Key Takeaway: Soft-NMS refines post-processing by penalizing rather than eliminating overlapping detections, preserving more valid boxes while still suppressing duplicates—especially valuable in crowded or occluded scenarios.