Search

Search papers and lessons

You Only Look Once: Unified, Real-Time Object Detection

Joseph Redmon, Santosh Divvala, Ross Girshick et al. · 2015

YOLO treats object detection as one regression problem: a single convolutional network sees the whole image once and outputs boxes, confidences and class scores, which made real-time detection practical.

On this page

  • Colour = topic mix
  • Calculus
  • Discrete math
  • Linear algebra
  • Probability
  • Neural network basics
  • Computer vision
  • ReadReady to readNot yet

TL;DR

YOLO is a 2015 paper by Joseph Redmon and colleagues that turns object detection into a single pass through one neural network. The network splits the image into a grid, and each grid cell predicts a few boxes, a confidence for each box, and a set of class probabilities, all in one output array. The base model ran at 45 frames per second on a Titan X GPU and a smaller version ran at 155, which made detection fast enough for live video.

Builds on: Object Detection, Convolutional Neural Network, Mean Squared Error, Intersection over Union · Leads to: Anchor Box, Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks

Why it mattered

Before YOLO, the accurate detectors were slow multi-stage pipelines. R-CNN, published in 2014, chained several separately tuned stages and took more than 40 seconds per image at test time, as the paper reports. The only real-time detector the authors found was a GPU version of the deformable parts model at 30 frames per second, and it scored only 26.1 mAP on Pascal VOC 2007.

YOLO showed that one network could do the whole job: it made 98 boxes per image, ran once per image, and reached 45 frames per second with 63.4 mAP on the same benchmark. Semantic Scholar lists about 50,000 citations for the paper as of November 2026.

Its main idea, one grid-based pass that predicts boxes and classes together, became the template for the one-stage family of detectors. Later YOLO versions are still used in robotics and video analysis because the speed trade-off it introduced is still the reason people choose this design.

History

Before 2015, deformable parts models were the strongest approach for many years, and R-CNN in 2014 brought convolutional features to detection but kept separate stages. Fast R-CNN and Faster R-CNN in 2015 sped up that pipeline, but the YOLO authors noted that even these were far from real time.

YOLO was posted to arXiv in June 2015 and published at CVPR 2016. It caught on because it was simple to build and fast enough to run on a webcam, which the authors demonstrated. Later versions improved its accuracy and are still widely used.

The problem

Object detection asks for two things at once. For every object in an image, the system must say what it is (a class such as dog or car) and where it is (a rectangle called a bounding box). Accuracy is measured with mean average precision, or mAP: for each class, a detector is scored on how well its ranked predictions trace out Precision and Recall as the threshold changes, and the scores are averaged over the classes. A detector that finds more true objects with fewer false alarms scores higher.

Earlier systems solved this by reusing classifiers. Deformable parts models ran a classifier at many positions and scales, so the cost grew with the number of windows examined. R-CNN instead generated candidate boxes with a separate proposal method (Selective Search), extracted features with a convolutional network, scored boxes with an SVM, adjusted the boxes with a linear model, and removed duplicates with Non-Maximum Suppression. Each part was trained separately and none of them was trained for the final detection score. That is why the authors called these pipelines slow and hard to optimise.

The question YOLO asks is simple: can one network, trained directly on a loss that measures detection quality, be fast enough for real-time video and accurate enough to matter?

How it works

Take a tiny instance. The image is split into a 2 by 2 grid of cells, each cell predicts one box, and there are two classes, cat and dog. The output array has shape 2 by 2 by 7, which is 28 numbers. Here is the path of one dog in the bottom-right cell.

  1. Input. The network receives the whole image once. There is no sliding window and no list of proposals. In the paper the input is 448 by 448 pixels, and the grid is 7 by 7.
  2. Each cell writes 7 numbers. One box (x, y, w, h), one confidence, and two class probabilities. Check: 2 times 2 cells, each with 7 numbers, gives 28.
  3. One cell is responsible. The dog's centre falls in the bottom-right cell, so that cell is responsible for the dog. The other three cells should predict confidence near zero.
  4. Box numbers mean something specific. The x and y values are offsets inside the cell, between 0 and 1. The w and h values are fractions of the whole image. Check: the bottom-right cell has column index 1 out of 2 cells, so with x = 0.4 the box centre sits at (1 + 0.4) / 2 = 0.7 across the image.
  5. Multiply to get a class score. Suppose the cell predicts confidence 0.75, dog probability 0.8 and cat probability 0.2. The dog score is 0.8 times 0.75 = 0.6. The cat score is 0.2 times 0.75 = 0.15. Check: the two class scores are the probabilities scaled by the same confidence.
  6. Threshold and clean up. Keep boxes whose score is at least 0.5. The dog box with score 0.6 stays and the cat score 0.15 is dropped. If neighbouring cells had also predicted this dog, non-maximum suppression would keep only the best one.

The real network does the same thing at a larger scale. A convolutional network turns the 448 by 448 image into a 7 by 7 by 30 array for Pascal VOC, where each cell predicts two boxes and twenty class probabilities.

flowchart LR
  A["Image resized to 448 by 448"] --> B["24 convolutional layers and 2 fully connected layers"]
  B --> C["7 by 7 by 30 output: 2 boxes plus 20 class probabilities per cell"]
  C --> D["Class score = class probability times box confidence"]
  D --> E["Keep scores above threshold"]
  E --> F["Non-maximum suppression removes duplicates"]
  F --> G["Final labelled boxes"]

Worked examples

Example
Example 1: one cell's score (tiny)
  1. A cell predicts confidence 0.75.
  2. Its dog probability is 0.8.
  3. Multiply: 0.8 times 0.75 = 0.6.
  4. Compare with the threshold 0.5. Since 0.6 is larger, the dog box is kept.

Interpretation: the box is confident that a dog is there and that the box fits it reasonably well.

Example
Example 2: the loss for one object cell (standard)

Setup: one object cell. Its responsible box predicts x = 0.4, y = 0.6, w = 0.25, h = 0.25. The target is x = 0.5, y = 0.5, w = 0.36, h = 0.36. The responsible box's predicted confidence is 0.6 against a target overlap of 0.8. The other box in the cell predicts confidence 0.3 against a target of 0. The class probabilities are dog 0.7 and cat 0.3, against targets 1 and 0.

  1. Position error: (0.4 minus 0.5) squared is 0.01, and (0.6 minus 0.5) squared is 0.01. The sum is 0.02. Times 5 gives 0.10.
  2. Size error: the square roots are 0.5 for the prediction and 0.6 for the target, so each side contributes (0.5 minus 0.6) squared = 0.01. The sum is 0.02. Times 5 gives 0.10.
  3. Confidence error for the responsible box: (0.6 minus 0.8) squared = 0.04.
  4. Empty-box confidence error: (0.3 minus 0) squared = 0.09. Times 0.5 gives 0.045.
  5. Class error: (0.7 minus 1) squared is 0.09, and (0.3 minus 0) squared is 0.09. The sum is 0.18.
  6. Total: 0.10 plus 0.10 plus 0.04 plus 0.045 plus 0.18 = 0.465.

Interpretation: the coordinate terms were multiplied by 5, so a small position error costs more than a small confidence error. This is the paper's reason for the weighting.

Example
Example 3: the real-time budget (realistic)

The paper reports speeds from Table 1 in the Results section. We turn frames per second into the time one frame takes.

  1. YOLO at 45 frames per second: 1,000 ms divided by 45 is about 22.2 ms per frame.
  2. Fast YOLO at 155 frames per second: 1,000 divided by 155 is about 6.45 ms per frame.
  3. Fast R-CNN at 0.5 frames per second: 1,000 divided by 0.5 is 2,000 ms, which is 2 seconds per frame.
  4. Speed ratio, YOLO against Fast R-CNN: 45 divided by 0.5 is 90. YOLO is 90 times faster.
  5. Check against the paper: the authors say YOLO processes streaming video with less than 25 ms of latency, and 22.2 ms is inside that bound.

Try it: Faster R-CNN with the ZF network runs at 18 frames per second. How many milliseconds does one frame take, and how many times slower is it than YOLO at 45 frames per second?

Answer: 1,000 divided by 18 is about 55.6 ms per frame, and 45 divided by 18 is 2.5, so it is 2.5 times slower than YOLO. The paper makes the same comparison.

The math

Definition: YOLO output

With an S by S grid, B boxes per cell and C classes, the network outputs a tensor of shape S by S by (B times 5 plus C). Each box contributes five numbers (x, y, w, h and a confidence), and each cell contributes C class probabilities once, shared by its boxes.

Step 2 in symbols: the output tensor

The paper's setting for Pascal VOC is S = 7, B = 2 and C = 20. The output size is 7 times 7 times (2 times 5 plus 20) = 7 times 7 times 30 = 1,470 numbers. The toy example in the walkthrough used S = 2, B = 1 and C = 2, which gives 2 times 2 times (1 times 5 plus 2) = 28.

Step 3 in symbols: confidence and responsibility

The confidence of box j in cell i is defined as

confij=Pr⁡(Object)×IOUpredtruth\text{conf}_{ij} = \Pr(\text{Object}) \times \text{IOU}^{\text{truth}}_{\text{pred}}

where Pr⁡(Object)\Pr(\text{Object}) is the probability that the cell contains an object's centre, and IOU\text{IOU} is the overlap between the predicted box and the true box. If no object is present, the target confidence is zero. If an object is present, the target is the overlap itself, so a confident box must also be a well-fitted box.

The indicator 1ijobj\mathbb{1}^{\text{obj}}_{ij} equals 1 for the one box in an object cell that has the highest overlap with the ground truth. That box is the "responsible" predictor. The other boxes in that cell use 1ijnoobj\mathbb{1}^{\text{noobj}}_{ij}.

Step 4 in symbols: box parameterisation

Let x and y be the box centre offsets inside the cell, both between 0 and 1. Let w and h be the box width and height as fractions of the image, also between 0 and 1. The network predicts w\sqrt{w} and h\sqrt{h} rather than ww and hh. Square roots shrink the penalty for large boxes, so a small error on a large box costs less than the same error on a small box.

Step 5 in symbols: class-specific score

At test time the class score multiplies the class probability by the box confidence:

Pr⁡(Classc∣Object)×Pr⁡(Object)×IOU=Pr⁡(Classc)×IOU\Pr(\text{Class}_c \mid \text{Object}) \times \Pr(\text{Object}) \times \text{IOU} = \Pr(\text{Class}_c) \times \text{IOU}

Each box therefore gets one score per class, and that score reflects both whether the class is present and how well the box fits.

The training loss

Training minimises a sum of squared errors with five parts. The coordinate terms are multiplied by λcoord=5\lambda_{\text{coord}} = 5 and the empty-box confidence term by λnoobj=0.5\lambda_{\text{noobj}} = 0.5. Each squared term compares a predicted value with its target.

L=λcoord∑i=0S2∑j=0B1ijobj[(xi−x^i)2+(yi−y^i)2]+λcoord∑i=0S2∑j=0B1ijobj[(wi−w^i)2+(hi−h^i)2]+∑i=0S2∑j=0B1ijobj(Ci−C^i)2+λnoobj∑i=0S2∑j=0B1ijnoobj(Ci−C^i)2+∑i=0S21iobj∑c∈classes(pi(c)−p^i(c))2\begin{aligned} \mathcal{L} = {} & \lambda_{\text{coord}} \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}^{\text{obj}}_{ij} \left[ (x_i - \hat{x}_i)^2 + (y_i - \hat{y}_i)^2 \right] \\ & + \lambda_{\text{coord}} \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}^{\text{obj}}_{ij} \left[ (\sqrt{w_i} - \sqrt{\hat{w}_i})^2 + (\sqrt{h_i} - \sqrt{\hat{h}_i})^2 \right] \\ & + \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}^{\text{obj}}_{ij} (C_i - \hat{C}_i)^2 \\ & + \lambda_{\text{noobj}} \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}^{\text{noobj}}_{ij} (C_i - \hat{C}_i)^2 \\ & + \sum_{i=0}^{S^2} \mathbb{1}^{\text{obj}}_{i} \sum_{c \in \text{classes}} (p_i(c) - \hat{p}_i(c))^2 \end{aligned}

The first two lines are the box position and size errors for responsible boxes. The third is the confidence error for responsible boxes. The fourth is the confidence error for empty boxes. The fifth is the class error, counted only in cells that contain an object. The class error is charged once per cell, not once per box, which matches the one-set-of-classes-per-cell design.

Results

The paper's main comparison is on Pascal VOC 2007, with the mAP and frame rate of each system from Table 1.

DetectorTraining datamAPFrames per second
100 Hz DPM200716.0100
30 Hz DPM200726.130
Fast YOLO2007 and 201252.7155
YOLO2007 and 201263.445
Fast R-CNN2007 and 201270.00.5
Faster R-CNN VGG-162007 and 201273.27
Faster R-CNN ZF2007 and 201262.118
YOLO VGG-162007 and 201266.421

What the numbers mean. YOLO is the fastest of the detectors that reach at least 60 mAP, and Fast YOLO is more than twice as accurate as earlier real-time systems. Fast R-CNN and Faster R-CNN are more accurate, but they are far from real time.

Error analysis. On VOC 2007 the authors split YOLO's errors into localisation, similar-class, other-class and background errors. Localisation errors were more common than all the others combined. Fast R-CNN made fewer localisation errors but more background errors. Combining the two, the authors report that rescoring Fast R-CNN detections with YOLO raised Fast R-CNN's VOC 2012 result by 2.3 percent.

Limits. On VOC 2012 YOLO scored 57.9 percent mAP, below the best systems of the time. It was weaker on small objects, such as bottles and sheep. Non-maximum suppression added 2 to 3 percent mAP.

Generalisation. When trained on natural photographs and tested on artwork datasets, YOLO's average precision dropped less than that of R-CNN, which the authors attribute to YOLO learning the size, shape and layout of objects rather than only textures.

Common mistakes and tradeoffs

It is tempting to think that one look at the image means YOLO handles one object at a time. In fact the single pass covers the whole image and every grid cell at once, so the cost does not grow with the number of objects in the way that sliding windows do.

It is tempting to think that the confidence score is the probability that an object is present. In fact it is the probability of an object multiplied by the overlap between the predicted box and the true box. A box that is in the right place but poorly sized gets a lower confidence.

It is tempting to think that a faster detector must be a worse one in every way. In fact YOLO made more localisation errors than Fast R-CNN, but it made fewer background errors: Fast R-CNN had 13.6 percent of its top detections on empty background, almost three times the rate of YOLO. Its errors are of a different kind.

It is tempting to think that each cell can detect many objects. In fact each cell predicts only two boxes and one set of class probabilities, so YOLO struggles with small objects in groups, such as a flock of birds.

When to use it: when speed matters and whole-image context helps, for example video, robotics and driver assistance. When not to use it: when small objects must be found precisely. Alternatives: two-stage detectors such as Faster R-CNN are often more accurate at a lower frame rate, and later one-stage detectors narrowed the accuracy gap.

Recap

  • Object detection needs both a class and a box for every object.
  • Older systems chained separate parts, such as proposals, classifiers and box fixers, each trained separately.
  • YOLO divides the image into a grid. Each cell predicts boxes, confidences and class probabilities in one output array.
  • Class score equals class probability times box confidence, and non-maximum suppression removes duplicates.
  • The loss weights coordinate errors more than confidence errors on empty boxes, and it is trained end to end.
  • The result is real-time detection at 45 frames per second, with the cost of weaker small-object and precise-localisation performance.

Next, read Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks to see the two-stage alternative, and Anchor Box for the later idea of fixed box templates.

Reading guide

Check yourself

QuestionRecall: what does the grid cell that contains an object's centre do?Show answer

It is responsible for that object. It predicts the box, the confidence and the class probabilities for the object, and the training loss penalises the box and class errors only for that cell's responsible predictor.

QuestionCompute: a YOLO-style detector uses S = 7, B = 2 and C = 20. How many numbers does one image's output contain?Show answer

Each cell has B times 5 plus C = 2 times 5 plus 20 = 30 numbers. There are 7 times 7 = 49 cells, so the output has 49 times 30 = 1,470 numbers.

QuestionWhy: why does the loss multiply coordinate errors by 5 and empty-box confidence errors by 0.5?Show answer

Most cells contain no object, so their confidence errors would otherwise outnumber the object terms and drown out the box and class errors. Weighting empty-box confidence by 0.5 reduces that effect, and weighting coordinates by 5 makes accurate localisation matter more, since the detector's goal is accurate boxes.

QuestionApplied: a team wants YOLO for spotting distant pedestrians, which appear as small objects in the image. What limitation should they expect?Show answer

YOLO struggles with small objects because each cell predicts only two boxes and the coarse grid gives less detail for small regions. The team should test on their own distant-pedestrian data and consider a higher-resolution input or a two-stage detector if the small-object recall is too low.

Sources

Read the full paper

Joseph Redmon, Santosh Divvala, Ross Girshick et al., 2015. arXiv:1506.02640