YOLO Architecture
YOLO frames object detection as a single regression problem, letting one network look at an image once and predict boxes and classes together.
Why Does This Exist?
Before YOLO, detection was a slow pipeline. R-CNN methods generated thousands of region proposals, ran a classifier on each one, then cleaned up duplicates, which was accurate but far from real-time. Self-driving cars, robotics, and live video cannot wait for thousands of classifier runs per frame.
YOLO reframed the whole task as one regression problem. A single convolutional network sees the image once and directly predicts every bounding box plus its class probabilities in one forward pass. This page covers the grid rule, the output tensor, the worked NMS cleanup, and the small-object price of that speed. Proposals-based two-stage craft is the alternative, and the cleanup step has its own page under non-maximum suppression.
Think of It Like This
The efficient mail sorter
A sorter watches a fast conveyor belt with a laser grid drawn across it. Instead of pausing the belt to inspect every inch with a magnifying glass, the sorter takes one glance at the whole grid and calls out per zone: a medium box centered here, a small envelope centered there.
The glance is the single forward pass, each grid zone is responsible only for objects centered inside it, and overlapping shouts about the same parcel get merged into one. The analogy stops at learning: the sorter trained for years, while YOLO learns its glance from labeled boxes by gradient descent.
How It Actually Works
The grid responsibility rule
YOLO divides the image into an grid, in the original paper. The core rule is that if the center of an object falls into a grid cell, that cell is responsible for detecting it. Each cell predicts bounding boxes, originally, with five numbers each: center and relative to the cell bounds, width and height relative to the whole image, and a confidence score that blends whether anything is there with how good the box is.
One set of classes per cell
Each cell also predicts conditional class probabilities, , one set per cell regardless of . With , , , the output tensor is , which is numbers from a single pass.
Worked NMS example
Neighboring cells often fire on the same object, so YOLO sorts boxes by final score, , and suppresses any box overlapping a kept one above the IoU threshold. Take box A at score and box B at score . Both are , intersection is , union is , so . Above a threshold, B is suppressed and A survives. A distant box at overlaps neither and is kept.
Code
IoU plus greedy NMS on the worked boxes:
def iou(a, b): ix0, iy0 = max(a[0], b[0]), max(a[1], b[1]) ix1, iy1 = min(a[2], b[2]), min(a[3], b[3]) inter = max(0, ix1 - ix0) * max(0, iy1 - iy0) ua = (a[2] - a[0]) * (a[3] - a[1]) ub = (b[2] - b[0]) * (b[3] - b[1]) return inter / (ua + ub - inter)
boxes = [((10, 10, 50, 50), 0.9), ((12, 12, 52, 52), 0.7), ((100, 100, 140, 140), 0.8)]print(round(iou(boxes[0][0], boxes[1][0]), 4))# -> 0.8223
kept = []for b, s in sorted(boxes, key=lambda t: -t[1]): if all(iou(b, k) < 0.5 for k, _ in kept): kept.append((b, s))print(kept)# -> [((10, 10, 50, 50), 0.9), ((100, 100, 140, 140), 0.8)]The overlap kills the weaker duplicate while the distant box survives, matching the hand computation.
Watch Out For
The small object crowd problem
Each cell predicts a fixed number of boxes and one class set, so a flock of small birds inside a single cell cannot all be predicted. The symptom is clustered small objects detected as one or missed entirely. Later versions add anchor boxes and feature pyramids to soften this, but dense crowds remain the weak spot.
Thresholding confidence instead of the final score
Confidence is , not the class probability, so thresholding it alone keeps well-localized boxes of the wrong class. The symptom is confident mislabeled boxes surviving filtering. Always multiply by the conditional class probability first and threshold the product.
The Quick Version
- YOLO reframes detection as one regression: one network, one forward pass, all boxes and classes.
- Each cell owns objects centered inside it and predicts boxes plus one class distribution.
- Original output is , which is numbers per image.
- Worked NMS: boxes at IoU collapse to the stronger one above a threshold.
- Real-time speed costs small-object accuracy where crowds share one cell.