← All answersObject detection concepts

How does the YOLO (You Only Look Once) algorithm predict boxes in a single pass?

Short answer

YOLO runs the whole image through one convolutional network a single time. The network outputs a grid, and every grid cell predicts a few bounding boxes, an objectness score for each, and class probabilities. Everything is produced at once - that's the 'you only look once' part - then non-max suppression removes duplicate boxes for the same object.

The insight that made YOLO fast is treating detection as a single regression problem instead of a pipeline. One pass in, all predictions out.

What comes out of the network

  • A spatial grid over the image (features downsampled from the original).
  • Per cell: a handful of candidate boxes as (x, y, w, h) offsets.
  • Per box: an objectness score - how confident the model is that a box contains any object.
  • Per box or cell: class probabilities for what that object is.

Multiply objectness by class probability and you get a confidence for each (box, class). Threshold on that, then run non-max suppression to collapse the many overlapping boxes that fire for the same object into one. Modern YOLO versions add multi-scale prediction (via an FPN-style neck) so small and large objects are handled by different grid resolutions.

from ultralytics import YOLO

model = YOLO("yolo11n.pt")
results = model("street.jpg", conf=0.25)  # one pass, all boxes at once

for box in results[0].boxes:
    cls = model.names[int(box.cls)]
    conf = float(box.conf)
    x1, y1, x2, y2 = box.xyxy[0].tolist()
    print(f"{cls} {conf:.2f} at ({x1:.0f},{y1:.0f})-({x2:.0f},{y2:.0f})")

Stuck on this in a real project?

Book a free call and I’ll give you a straight answer on your specific case.

Book a consultation