Abstract
The widely adopted sequential variant of Non-Maximum Suppression (or Greedy-NMS) is a crucial module for object-detection pipelines. Unfortunately, for the region proposal stage of two/multi-stage detectors, NMS is turning out to be a latency bottleneck due to its sequential nature. In this article, we carefully profile Greedy-NMS iterations to find that a major chunk of computation is wasted in comparing proposals that are already far apart and have a small chance of suppressing each other. We address this issue by comparing only those proposals that are generated from nearby anchors. The translation-invariant property of the anchor lattice affords the generation of a lookup table, which provides efficient access to nearby proposals during NMS. This leads to an Accelerated NMS algorithm which leverages Spatially Aware Priors, or ASAP-NMS, and improves the latency of the NMS step from 13.6ms to 1.2ms on a CPU without sacrificing the accuracy of a state-of-the-art two-stage detector on COCO and VOC datasets. Importantly, ASAP-NMS is agnostic to image resolution and can be used as a simple drop-in module during inference.
Introduction: The NMS Bottleneck
In modern object detection, Non-Maximum Suppression (NMS) serves as the critical final step to prune redundant bounding box predictions. When a model like Faster R-CNN processes an image, it generates thousands of overlapping "proposals." NMS sorts these by confidence and removes any box that overlaps significantly with a higher-scoring neighbor.
While neural network backbones have seen massive speedups via GPU acceleration, NMS remains a sequential, CPU-bound bottleneck. Standard "Greedy-NMS" compares every high-scoring proposal against every other proposal, resulting in a computational complexity of $O(kN)$. The core inefficiency lies in calculating the Intersection over Union (IoU) for proposals that are physically far apart in the image—proposals that could never realistically suppress one another.
Methodology: Leveraging Spatially Aware Priors
ASAP-NMS (Accelerated NMS using Spatially Aware Priors) optimizes this process by using the anchor grid as a spatial proxy. Anchors are the fixed set of reference boxes used by the Region Proposal Network (RPN) to generate predictions.
The Lookup Table
Because anchors are placed on a regular, translation-invariant grid, the potential overlap between any two anchors depends only on their relative distance and shapes, not their absolute coordinates. ASAP-NMS pre-computes a lookup table ($N_{\mathcal{T}}$) that identifies which anchors have a significant overlap (defined by a threshold $\gamma$).
Spatially Constrained Comparison
During inference, when the algorithm evaluates a high-scoring proposal, it only checks it against other proposals whose "parent" anchors are marked as "nearby" in the pre-computed lookup table. This effectively transforms a global search into a local one, pruning the vast majority of unnecessary IoU calculations before they are even attempted.
Experimental Results
ASAP-NMS was evaluated on the MS-COCO and Pascal VOC datasets, demonstrating that algorithmic optimization can yield hardware-agnostic speedups without compromising precision.
- Latency Reduction: On a standard CPU, NMS latency for a high-resolution image (800x1280) dropped from 13.6ms to 1.2ms.
- Accuracy Parity: Unlike other fast NMS variants (like MaxPool-NMS) that trade accuracy for speed, ASAP-NMS maintains the exact same mean Average Precision (mAP) as standard Greedy-NMS (e.g., 44.2% on COCO).
- Real-time Viability: When integrated with the SNIPER detector on a V100 GPU, the system achieved 25 FPS, making high-accuracy two-stage detectors viable for real-time applications.
Conclusion
ASAP-NMS solves the "chicken and egg" problem of NMS—needing to know distances to avoid calculating distances—by utilizing the fixed geometry of the anchor grid. As a drop-in replacement that requires no retraining, it offers a significant performance boost for existing two-stage detection pipelines, particularly on edge devices where CPU resources are limited.
Summary updated