Back to ML Engineer Mind Map
中文·English
💻 ML EngineerID: mle-coding-nms-iou

Live Coding: NMS & IoU Matrix

手写目标检测 NMS 与 IoU 矩阵
🎯Core Definition
Live Coding Non-Maximum Suppression (NMS) & Intersection over Union (IoU) represents the quintessential computer vision coding problem testing bounding-box coordinate geometry and greedy filtering algorithms; it comprises 2 stages: 1) Vectorized IoU Calculation: given boxes A,BRM×4A, B \in \mathbb{R}^{M \times 4} ([x1,y1,x2,y2][x_1, y_1, x_2, y_2]), leveraging numpy broadcasting to compute pairwise intersection coordinates (xinter1=max(Ax1,Bx1)x_{\text{inter1}} = \max(A_{x1}, B_{x1})), yielding IoU=Area(Intersection)Area(A)+Area(B)Area(Intersection)\text{IoU} = \frac{\text{Area}(\text{Intersection})}{\text{Area}(A) + \text{Area}(B) - \text{Area}(\text{Intersection})}; 2) Greedy NMS Filtering: sorting boxes by confidence descending, iteratively appending the top box to the keep-list and discarding all remaining candidates with IoU>threshold\text{IoU} > \text{threshold}.
💡Use Cases
Object detection post-processing (YOLO, Faster R-CNN), OCR text-box deduplication, and autonomous driving point-cloud 3D box filtering.
Key Problems Solved
Dense anchor-based and anchor-free object detectors emit dozens of redundant overlapping proposals around a single physical object; NMS eliminates duplicates to yield crisp, non-overlapping detections.
🎯5 High-Frequency Exam Points
1
Write the complete Pure Numpy implementation of vectorized IoU and greedy NMS from scratch?
2
Explain why pixel width calculations add 1 (w=x2x1+1w = x_2 - x_1 + 1) for discrete raster grids vs continuous float coordinates?
3
Explain how Soft-NMS uses continuous Gaussian score decay to retain heavily occluded neighboring objects that hard NMS erroneously deletes?
4
Explain the coordinate-offset trick enabling multi-class batched NMS execution in a single vector operation?
5
How does DETR's bipartite Hungarian matching loss eliminate the need for heuristic NMS post-processing entirely?
🔗Foundational Prerequisite Cards (Click to Review)
Updated 2026-08-14
🎯
Test Your Knowledge: Practice Questions for "Live Coding: NMS & IoU Matrix"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardLive Coding: Vectorized K-MeansNext CardLive Coding: Logistic Regression SGD

🔗 More ML Engineer Knowledge Cards

Bias-Variance Tradeoff & OverfittingLoss Function Taxonomy & GradientsOptimizer Convergence & MomentumEnsemble Stacking & Blending