Every detector depends on two small tools: a way to measure how well two boxes overlap, and a way to remove duplicate boxes. Build both from scratch, see how they shape precision and recall, then run a pretrained Faster R-CNN in PyTorch and TensorFlow.
Detection answers all three at once, for every object. The sliding-window calculator shows why brute force is too slow, which is why proposals and then learned detectors were invented.
The green box is the ground truth. Move and resize the red prediction and watch the overlap.
A detector fires many overlapping boxes on one object. NMS sorts them by score, keeps the best, discards any box that overlaps it by more than the threshold τ, and repeats. The seven boxes below are two objects plus a smaller third object next to the second.
Each detection has a confidence score, and IoU has already decided whether it is a true positive. A threshold keeps the detections above it. This toy set has 24 detections and 16 real objects. The AP is computed exactly from this list.
Faster R-CNN has a first stage that proposes regions that might hold an object, and a second stage that classifies each region and refines its box. The three generations differ in how much work is shared.
torchvision returns pixel boxes as [x1, y1, x2, y2]. TF-Hub returns fractions of the image as [y1, x1, y2, x2]. Convert a TF-Hub box and see why normalised boxes survive resizing.
Copy each cell into Colab and run them in order. Tasks 1 to 4 use NumPy only. Task 5 uses PyTorch and Task 6 uses TensorFlow, so you can do either in one runtime and restart for the other. Comments in the code explain each step.
Answers are saved in this browser only. Open a hint after you have tried.