A bounding box is a rectangle that tightly encloses an object in an image, defined by coordinates usually as (x_min, y_min, x_max, y_max). It helps locate and identify objects.
Click to reveal answer
beginner
How do you convert bounding boxes from (x, y, width, height) format to (x_min, y_min, x_max, y_max)?
You keep x_min = x, y_min = y, then calculate x_max = x + width - 1 and y_max = y + height - 1.
Click to reveal answer
intermediate
What is Intersection over Union (IoU) in bounding box handling?
IoU measures how much two bounding boxes overlap. It is the area of overlap divided by the area of union of the two boxes. It helps evaluate detection accuracy.
Click to reveal answer
intermediate
Why is Non-Maximum Suppression (NMS) used in bounding box handling?
NMS removes duplicate bounding boxes that detect the same object by keeping only the box with the highest confidence score and discarding others with high overlap.
Click to reveal answer
beginner
How can bounding boxes be normalized for neural network input?
Bounding box coordinates can be divided by the image width and height to scale them between 0 and 1, making them independent of image size.
Click to reveal answer
What does the bounding box format (x_min, y_min, x_max, y_max) represent?
ACenter coordinates only
BCenter coordinates and width/height
CTop-left and bottom-right corners of the box
DWidth and height only
✗ Incorrect
The format (x_min, y_min, x_max, y_max) defines the top-left and bottom-right corners of the bounding box.
What is the main purpose of Non-Maximum Suppression (NMS)?
ATo remove overlapping boxes for the same object
BTo increase the number of bounding boxes
CTo resize images
DTo normalize bounding box coordinates
✗ Incorrect
NMS removes overlapping bounding boxes that detect the same object, keeping only the best one.
How is Intersection over Union (IoU) calculated?
ADifference between box widths
BArea of overlap divided by area of union
CSum of areas of two boxes
DDistance between box centers
✗ Incorrect
IoU is the ratio of the overlapping area to the combined area of two bounding boxes.
Why normalize bounding box coordinates before feeding to a model?
ATo convert coordinates to pixels
BTo remove bounding boxes
CTo increase coordinate values
DTo make coordinates relative to image size
✗ Incorrect
Normalization scales coordinates between 0 and 1, making them independent of image size.
Which PyTorch tensor shape is typical for a batch of bounding boxes?
A[batch_size, num_boxes, 4]
B[4, num_boxes]
C[num_boxes, batch_size]
D[batch_size, 4]
✗ Incorrect
Bounding boxes are usually stored as [batch_size, number_of_boxes, 4_coordinates].
Explain how Non-Maximum Suppression (NMS) works and why it is important in bounding box handling.
Think about how multiple boxes might detect the same object and how to keep only one.
You got /4 concepts.
Describe the process to calculate Intersection over Union (IoU) between two bounding boxes.
Imagine two rectangles overlapping and how much they share.
You got /4 concepts.
Practice
(1/5)
1. What do the four numbers in a bounding box usually represent in PyTorch object detection tasks?
easy
A. Width, height, depth, and color
B. Center x, center y, width, height
C. Top-left corner x and y, width, height
D. Left, top, right, bottom coordinates of the box
Solution
Step 1: Understand bounding box format
Bounding boxes in PyTorch detection models are often represented by four numbers indicating the edges: left (x_min), top (y_min), right (x_max), and bottom (y_max).
Step 2: Compare options with standard format
Left, top, right, bottom coordinates of the box matches this format exactly, while others describe different formats or unrelated values.
Final Answer:
Left, top, right, bottom coordinates of the box -> Option D
A. The comparison between points and boxes tensors will fail due to shape mismatch
B. The logical AND operator '&' cannot be used with tensors
C. The code should use .all() to combine conditions
D. Points coordinates are reversed in the comparisons
Solution
Step 1: Check tensor shapes for broadcasting
Boxes shape is (4,), points shape is (2,2). Comparing points[:, 0] (shape 2) with boxes[:, 0] causes shape mismatch as boxes is 1D.
Step 2: Understand broadcasting rules
Direct element-wise comparison fails because points and boxes dimensions don't align for broadcasting in this code.
Final Answer:
The comparison between points and boxes tensors will fail due to shape mismatch -> Option A
Quick Check:
Shape mismatch causes error in element-wise comparison [OK]
Hint: Check tensor shapes before element-wise comparisons [OK]
Common Mistakes:
Assuming PyTorch auto-broadcasts all shapes
Using bitwise operators incorrectly
Mixing coordinate order in comparisons
5. You want to convert bounding boxes from (left, top, right, bottom) format to (center_x, center_y, width, height) in PyTorch. Which code snippet correctly performs this conversion for a tensor boxes of shape (N, 4)?