What is Non-maximum Suppression (NMS) in object detection?
NMS is a technique to remove duplicate bounding boxes by keeping only the box with the highest confidence score and discarding others that overlap too much with it.
Click to reveal answer
beginner
Why do we need Non-maximum Suppression in object detection?
Because object detectors often predict many overlapping boxes for the same object, NMS helps keep only the best box to avoid multiple detections of the same object.
Click to reveal answer
intermediate
What is the role of the IoU (Intersection over Union) threshold in NMS?
The IoU threshold decides how much overlap is allowed between boxes. Boxes with IoU above this threshold are considered duplicates and suppressed.
Click to reveal answer
intermediate
How does PyTorch implement Non-maximum Suppression?
PyTorch provides a function torchvision.ops.nms(boxes, scores, iou_threshold) that returns indices of boxes to keep after applying NMS.
Click to reveal answer
intermediate
What happens if the IoU threshold in NMS is set too low or too high?
If too low, many boxes are removed, possibly missing some objects. If too high, many overlapping boxes remain, causing duplicate detections.
Click to reveal answer
What does Non-maximum Suppression primarily remove?
ABackground pixels
BLow confidence scores
CSmall objects
DDuplicate bounding boxes with high overlap
✗ Incorrect
NMS removes duplicate bounding boxes that overlap too much, keeping only the one with the highest confidence.
In PyTorch, which function is used for Non-maximum Suppression?
Atorchvision.ops.nms()
Btorch.ops.torchvision.nms()
Ctorch.nms()
Dtorch.nn.NMS()
✗ Incorrect
The correct PyTorch function is torchvision.ops.nms() to perform Non-maximum Suppression.
What does the IoU threshold control in NMS?
AMaximum allowed overlap between boxes
BNumber of boxes to keep
CSize of the bounding box
DMinimum confidence score to keep a box
✗ Incorrect
IoU threshold controls the maximum allowed overlap between boxes before one is suppressed.
If the IoU threshold is set very high, what is the likely effect?
AMore boxes are removed
BMore duplicate boxes remain
CNo boxes are removed
DOnly the smallest boxes remain
✗ Incorrect
A high IoU threshold means boxes can overlap a lot before suppression, so more duplicates remain.
Which metric is used to measure overlap between bounding boxes in NMS?
ACosine similarity
BEuclidean distance
CIntersection over Union (IoU)
DManhattan distance
✗ Incorrect
IoU measures the overlap area divided by the union area of two boxes, used in NMS.
Explain how Non-maximum Suppression works and why it is important in object detection.
Think about how multiple boxes can cover the same object and how NMS helps keep only the best one.
You got /5 concepts.
Describe how to use PyTorch's NMS function including its inputs and outputs.
Consider what information you need to give the function and what you get back.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of Non-maximum Suppression (NMS) in object detection using PyTorch?
easy
A. To increase the number of detected boxes
B. To resize images before detection
C. To randomly select boxes for training
D. To remove overlapping bounding boxes and keep only the best ones
Solution
Step 1: Understand the role of NMS
Non-maximum suppression is used to filter out overlapping bounding boxes that represent the same object.
Step 2: Identify the goal of NMS
It keeps only the bounding box with the highest confidence score among overlapping boxes to avoid duplicate detections.
Final Answer:
To remove overlapping bounding boxes and keep only the best ones -> Option D
Quick Check:
NMS purpose = remove overlaps, keep best [OK]
Hint: NMS filters duplicates, keeping only top scoring boxes [OK]
Common Mistakes:
Thinking NMS increases detected boxes
Confusing NMS with image resizing
Assuming NMS randomly selects boxes
2. Which PyTorch function is commonly used to perform Non-maximum Suppression on bounding boxes and scores?
easy
A. torch.sort
B. torch.max
C. torch.ops.torchvision.nms
D. torch.argmax
Solution
Step 1: Identify the PyTorch NMS function
PyTorch provides a dedicated function called torch.ops.torchvision.nms to perform Non-maximum Suppression.
Step 2: Differentiate from other functions
torch.max, torch.sort, and torch.argmax do not perform NMS; they serve different purposes like finding max values or sorting tensors.
Final Answer:
torch.ops.torchvision.nms -> Option C
Quick Check:
PyTorch NMS function = torch.ops.torchvision.nms [OK]
Hint: Use torch.ops.torchvision.nms for Non-maximum Suppression in PyTorch [OK]
Common Mistakes:
Using torch.max instead of torch.ops.torchvision.nms
Confusing sorting functions with NMS
Trying torch.argmax for NMS
3. Given the following PyTorch code snippet, what will be the output tensor of indices after applying NMS?
B. Use torch.ops.torchvision.nms instead of torch.nms
C. Change boxes dtype to int
D. Sort scores before calling nms
Solution
Step 1: Check function availability
torch.nms is not a direct PyTorch function; NMS is accessed via torchvision ops as torch.ops.torchvision.nms.
Step 2: Correct function call
Replacing torch.nms with torch.ops.torchvision.nms fixes the error and runs NMS correctly.
Final Answer:
Use torch.ops.torchvision.nms instead of torch.nms -> Option B
Quick Check:
Correct NMS call = torch.ops.torchvision.nms [OK]
Hint: Use torchvision's nms via torch.ops.torchvision.nms [OK]
Common Mistakes:
Calling torch.nms directly
Changing box dtype unnecessarily
Adjusting IoU threshold without fixing function
5. You have detected multiple overlapping boxes with scores: [0.95, 0.9, 0.85, 0.6]. If you apply Non-maximum Suppression with a very low IoU threshold (e.g., 0.1), what is the expected effect on the number of boxes kept?
hard
A. Most boxes will be removed because even slight overlaps are suppressed
B. All boxes will be kept because the threshold is low
C. Only the box with the lowest score will be kept
D. Boxes will be randomly removed regardless of overlap
Solution
Step 1: Understand IoU threshold meaning
A low IoU threshold means boxes with even small overlaps are considered duplicates and suppressed.
Step 2: Predict effect on boxes
Because boxes overlap slightly, most will be removed except the highest scoring box, reducing the number kept.
Final Answer:
Most boxes will be removed because even slight overlaps are suppressed -> Option A