Inferensys

Glossary

Non-Maximum Suppression (NMS)

Non-Maximum Suppression (NMS) is a post-processing algorithm used in object detection to select the best bounding box from a set of overlapping candidate boxes that likely refer to the same object.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
ALGORITHM

What is Non-Maximum Suppression (NMS)?

A critical post-processing step in computer vision pipelines for real-time robotic perception.

Non-Maximum Suppression (NMS) is a post-processing algorithm used in object detection to select the single best bounding box from a cluster of overlapping candidate detections that likely refer to the same physical object. It operates by ranking all candidate boxes by a confidence score (e.g., class probability), selecting the highest-scoring box, and then suppressing all other boxes whose Intersection over Union (IoU) with it exceeds a predefined threshold. This eliminates redundant detections, ensuring each object is represented by one clean, high-confidence box, which is essential for downstream tasks like multi-object tracking (MOT) and robotic planning.

In real-time robotic perception, NMS is a computational bottleneck that must be optimized for low-latency execution on embedded hardware. Efficient implementations, often using TensorRT or custom kernels, are vital. Variations like Soft-NMS decay the scores of neighboring boxes instead of discarding them, improving detection in crowded scenes. For a robot, clean output from NMS directly feeds into sensor fusion and visuomotor control policies, where ambiguous or duplicate detections could cause erratic or unsafe physical actions.

ALGORITHM MECHANICS

Key Characteristics of NMS

Non-Maximum Suppression is a deterministic post-processing algorithm critical for cleaning up the output of object detectors. It operates on a set of candidate bounding boxes to eliminate redundant detections of the same object.

01

Core Function: Redundancy Elimination

The primary function of NMS is to select the single best bounding box from a cluster of overlapping candidate boxes that all likely refer to the same physical object. It does this by:

  • Sorting all candidate boxes for a given class by their confidence score (e.g., objectness or class probability).
  • Iteratively selecting the highest-scoring box as the 'winner'.
  • Suppressing (removing) all other boxes whose Intersection over Union (IoU) with the winner exceeds a predefined threshold (e.g., 0.5).
  • Repeating this process on the remaining boxes. This prevents the visual clutter of multiple boxes on a single object.
02

Critical Parameter: IoU Threshold

The Intersection over Union (IoU) threshold is the most critical hyperparameter controlling NMS behavior. It defines the overlap level at which two boxes are considered duplicates.

  • Low Threshold (e.g., 0.3): Aggressive suppression. Only very loosely overlapping boxes are kept, potentially missing objects that are close together.
  • High Threshold (e.g., 0.7): Permissive suppression. Allows more boxes to remain, which can lead to multiple detections on a single object.
  • Typical Default: 0.5 is a common starting point, balancing precision and recall. This value must be tuned for the specific object density and scale in the target application, such as robotics where objects may be in close proximity.
03

Sorting by Confidence Score

NMS is a greedy algorithm that relies on the assumption that the detection with the highest confidence score is the most accurate localization of the object. The algorithm's steps are:

  1. Sort All Detections: Order all bounding box proposals for a specific class by their confidence score, descending.
  2. Select and Keep: Take the top-scoring box and add it to the final output list.
  3. Compute IoU and Suppress: Calculate the IoU between this selected box and every other box in the list. Remove (suppress) all boxes where IoU > threshold.
  4. Iterate: Repeat steps 2-3 on the remaining, unsuppressed boxes until none are left. This sequential, score-dependent process ensures the most confident predictions are preserved.
04

Class-Agnostic vs. Class-Aware NMS

NMS can be applied in two primary modes, affecting how detections for different object classes are handled:

  • Class-Agnostic NMS: Suppression is performed on all boxes regardless of their predicted class label. Boxes of different classes can suppress each other if they overlap significantly, which is often undesirable. This is simpler but less accurate for cluttered scenes.
  • Class-Aware NMS (the standard): Suppression is performed independently per class. All boxes for 'person' are processed together, separate from boxes for 'car'. This prevents a high-confidence 'car' box from suppressing a valid, overlapping 'person' box, preserving detections in multi-object scenarios common in robotic perception.
05

Limitations and Advanced Variants

Standard Greedy NMS has known limitations that have led to the development of advanced variants:

  • Limitation: Occlusion & Close Proximity: With a fixed IoU threshold, it can incorrectly suppress valid detections for objects that are naturally close together or partially occluded (e.g., a crowd of people).
  • Soft-NMS: Instead of outright removing overlapping boxes, it attenuates (lowers) their confidence scores based on the IoU with the higher-scoring box. This gives them a chance to be selected later if they are indeed a separate object.
  • Weighted-NMS: Averages the coordinates of overlapping boxes (weighted by their confidence scores) to produce a refined, more accurate final bounding box, rather than just picking one.
  • Adaptive-NMS: Dynamically adjusts the IoU threshold based on the local object density or detection score, becoming more permissive in crowded regions.
06

Role in Real-Time Robotic Pipelines

In real-time robotic perception, NMS is a lightweight but crucial component in the post-processing stage of an object detection pipeline (e.g., after a YOLO or SSD network). Its characteristics directly impact system performance:

  • Deterministic & Fast: It adds minimal, predictable latency, which is essential for control loops.
  • Directly Affects Metrics: The choice of IoU threshold influences the system's precision (fewer false positives) and recall (fewer missed objects).
  • Downstream Impact: The cleaned bounding box list is passed to modules like Multi-Object Tracking (MOT), task planning, and visuomotor control. Erroneous suppression can cause an object's track to be lost, leading to planning failures.
  • Embedded Optimization: For deployment on edge devices, NMS is often hand-optimized or integrated into inference engines like TensorRT to minimize CPU overhead.
COMPARISON

NMS vs. Alternative Post-Processing Methods

A technical comparison of Non-Maximum Suppression against other algorithms used to refine object detection outputs by eliminating redundant bounding boxes.

Algorithm / FeatureNon-Maximum Suppression (NMS)Soft-NMSWeighted Boxes Fusion (WBF)DETR-Style Set Prediction

Core Mechanism

Greedy selection based on highest confidence score; suppresses all overlaps above IoU threshold.

Decays confidence scores of overlapping boxes as a continuous function of IoU; no immediate hard suppression.

Clusters overlapping boxes and fuses them into a single box via weighted averaging of coordinates and scores.

Eliminates post-processing; uses a transformer encoder-decoder to directly output a fixed-size set of non-overlapping predictions.

Handles Occlusion & Crowding

Preserves Localization Precision

Deterministic Output

Primary Hyperparameter

IoU threshold (e.g., 0.5)

Softening function & sigma parameter

IoU threshold for clustering

Loss function (e.g., Hungarian loss for bipartite matching)

Typical Inference Overhead

< 1 ms per image

~1-2 ms per image

~2-5 ms per image

N/A (integrated into forward pass)

Common Use Case

Real-time, single-model deployments (e.g., YOLO, SSD).

Scenes with moderate to high object density.

Ensemble methods and test-time augmentation.

End-to-end transformer-based detectors (e.g., DETR, Deformable DETR).

Key Limitation

Suppresses accurate but lower-confidence boxes in crowded scenes.

Can retain too many boxes if threshold is too soft, increasing false positives.

More computationally intensive than NMS; requires tuning of fusion weights.

Requires extensive training; can suffer from slower convergence than CNN-based detectors.

NON-MAXIMUM SUPPRESSION

Frequently Asked Questions

Non-Maximum Suppression (NMS) is a critical post-processing algorithm in real-time object detection pipelines. These questions address its core mechanics, variations, and practical implementation for robotics and embedded vision systems.

Non-Maximum Suppression (NMS) is a post-processing algorithm used in object detection to eliminate redundant, overlapping bounding boxes that refer to the same object, selecting only the most confident prediction. It works by first sorting all candidate boxes by their confidence score. The box with the highest score is selected and all other boxes with a significant overlap (measured by Intersection over Union (IoU)) exceeding a predefined threshold are suppressed. This process repeats iteratively on the remaining boxes until all candidates are either selected or suppressed.

Key Steps:

  1. Sort all detected bounding boxes by their confidence score (descending).
  2. Select the box with the highest score and add it to the final output list.
  3. Calculate the IoU between this selected box and all other remaining boxes.
  4. Remove (suppress) all boxes where IoU > nms_threshold.
  5. Repeat steps 2-4 for the next highest-scoring box among those still remaining.
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.