Deep Learning · Topic 1 · Learn Yolo from scratch A-Z · Interactive sheet · Beginner

The Learn Yolo from scratch A-Z Blueprint

Theory and Practical

YOLO finds every object in a photo by looking at it only once: one run of one network turns the whole picture into a grid of boxes and labels. That single look is what makes it fast enough for live video.

Every number on this page is clickable. Every underlined term has a definition.

Before you start: what a convolution is (CNN), how a deep image network is stacked from layers (AlexNet & VGG-16), and what a box around an object means (explained in section 01).

448 → 7 × 7 × 30
shape path
…
parameters
…
multiply-adds per photo
45 fps
speed
63.4 %
mAP, VOC 2007
1 look
the design rule
01

The challenge: find every object, fast

Object detection asks two questions at once, what is in the photo and where, and before YOLO answering them took seconds per photo.

Two kinds of answer for the same photo

20
classes in PASCAL VOC
≈ 2,000
regions checked by R-CNN
45 fps
YOLO, 2016
63.4 %
mAP, VOC 2007

Why it mattered

A camera delivers about 30 photos (frames) every second. A detector that needs seconds per photo is useless for a car, a robot or a drone. YOLO was the first detector that was both accurate enough and fast enough to watch live video.

timeline · click a chip
2014 R-CNN 2015 Faster R-CNN 2016 YOLO 2017 YOLOv2 2018 YOLOv3
02

Walk a photo through the network

Drag the scrubber or click a bead to follow one 448 × 448 photo through 24 convolution layers and 2 dense layers until it becomes a 7 × 7 × 30 block of answers.
input conv + leaky ReLU max-pool dense answer block
layer scrubberinput
what this layer does

input
parameters so far
0
multiply-adds so far
0
The photo is 448 pixels wide and the output grid is 7 cells wide. How many pixels wide is one grid cell on the original photo?
448 ÷ 7 = 64. Each of the 7 × 7 cells stands for a 64 × 64 pixel square of the photo, even though its answer is computed from the whole image.
03

The three ideas that made it work

A grid that shares out the work, a score that measures overlap, and a clean-up step that removes duplicates: try each with one control.
Idea 1 · the grid

The cell holding the centre is responsible

grid size S7 × 7

Click the photo to move the dog's centre.

Idea 2 · how good is a box?

IoU: overlap ÷ union

move the guessed box20 px
Idea 3 · remove duplicates

Non-max suppression

overlap limit0.5
Two boxes around the same dog overlap with IoU 0.8, and the overlap limit is 0.5. What does non-max suppression do?
0.8 is above the 0.5 limit, so the boxes are treated as duplicates of one object. Only the most confident one survives.
04

The defining rule: you only look once

Instead of running a classifier on thousands of candidate regions, YOLO runs one network once and reads every box from a single block of numbers.

Many looks or one look?

Suppose one run of the network takes 22 ms (that is YOLO's 45 fps). A region-by-region detector needs one run per region.

regions checked per photo2,000
many looks
one look (YOLO)
22 ms
≈ 45 photos / s
time = regions × time per run · YOLO: 1 × time per run

Illustration only: real two-step detectors later shared work between regions, but they still needed a separate region step.

The answer block

grid size S7
output = S × S × (B · 5 + C) = 7 × 7 × 30
1,470numbers in total
98candidate boxes (S × S × B)
the 30 numbers of one cell · click a group
With S = 7, B = 2 boxes per cell and C = 20 classes, how many numbers does one grid cell output?
Each box needs 5 numbers (x, y, width, height, confidence): 2 × 5 = 10. Add 20 class probabilities: 10 + 20 = 30.
05

Shapes by hand and by eye

One small formula gives the size of every layer's output: do it once with tiny numbers, then let the calculator handle YOLO's real layers.

Worked example by hand: a 4 × 4 input and one 3 × 3 filter

input 4 × 4
filter 3 × 3
output 2 × 2

Redo it on paper: put the stencil on the top-left corner, multiply each pair of numbers that sit on top of each other, add them up, then slide one step. The count of places is (4 − 3) ÷ 1 + 1 = 2 in each direction, so the output is 2 × 2.

The same rule for real layers

O = ⌊(N − K + 2P)/S⌋ + 1 ⌊ ⌋ = round down
input N448
filter K7
padding P3
stride S2
output size
filter sliding over the padded input → output map · click to pause100%
A 3 × 3 filter with padding 1 and stride 1 keeps a 56 × 56 input at 56 × 56. Why?
Without padding: 56 − 3 + 1 = 54. The border of 1 on each side adds 2: (56 − 3 + 2) ÷ 1 + 1 = 56.
06

Where the parameters live

Parameters are the numbers the network learns; count them layer by layer and one dense layer turns out to hold most of them.
100%
convdensepooling layers learn nothing, so they have no bar
click a bar

The arithmetic for that layer appears here.

Parameters

Work (multiply-adds)

per 448 × 448 photo
Why does the first dense layer hold so many parameters?
A dense layer has one parameter per input–output pair: 50,176 inputs × 4,096 outputs is about 205 million. A conv filter is small and shared across positions, so it needs far fewer.
07

The YOLO family

Every later version kept the one-look idea and changed the engine; click a row to compare depth, size, speed and score.
versionyearconv layersparametersspeedscore

Scores: mAP on PASCAL VOC 2007 unless noted. Parameters marked "computed" come from this page's layer list; the Fast YOLO row is a simplified 9-layer sketch.

version

Pick a row.

After v3. From 2020 onward many teams released their own versions (v4, v5, v8 and more), mostly with "nano" to "extra-large" sizes so you can trade speed for accuracy.

Fast YOLO runs about 3 times faster than YOLO but scores lower. What is the main reason?
Fewer layers means fewer multiply-adds (faster) but also less capacity to learn detail (lower mAP). It is a speed-for-accuracy trade.
08

The cost of looking

Count the multiply-adds for one photo, pick how fast your GPU is, and estimate the time for one photo, one pass over the training set and the whole original training run.
work for one photo
GPU speed (TFLOPS)10
photos per batch64

Assumes the GPU reaches 40 % of its peak, which is typical in practice. Training one photo costs about 3 × a forward pass (forward, then backward).

one photo
one batch (inference)
one epoch of training
original run: 135 epochs
Your GPU really delivers 4 TFLOPS. One photo needs 40 billion operations. Roughly how many photos per second can it handle?
4 TFLOPS = 4,000 billion operations per second. 4,000 ÷ 40 = 100 photos per second.
09

Reuse it instead of retraining it

Keep the pretrained layers that already know edges and shapes, replace the last layer for your own classes, and train only what you must: this is transfer learning.
click a block to freeze or train it
your number of classes C3
new output = 7 × 7 × (2 · 5 + C) =

framework-neutral recipe (pseudocode) · follows your clicks

        

Rule of thumb

Few photos (hundreds): freeze the backbone and train only the top. Thousands of photos: also unfreeze the detection layers. Always use a small learning rate for layers that were pretrained, so their knowledge is nudged, not erased.

You want to detect helmet, vest and person (3 classes) with S = 7 and B = 2. What is the new output block?
2 boxes × 5 numbers = 10, plus 3 class probabilities = 13. The grid stays 7 × 7.
10

History: accuracy or speed, then both

Detectors on the PASCAL VOC 2007 test set, in time order: switch between accuracy and speed and click a point for its story.
100%
click a point
In 2016 Faster R-CNN scored a higher mAP than YOLO. Why was YOLO still a big step?
YOLO ran at 45 fps against about 7 fps for Faster R-CNN, while keeping a usable 63.4 % mAP. Speed opened up live video, robots and cars.
11

Where it is used today

Fast detectors from the YOLO family run in cars, shops, farms and hospitals; tap a card to flip it, and the violet-edged cards are its successors.
A factory wants to count parcels on a belt at 60 frames per second on a small, cheap computer. Which choice fits best?
The task needs speed on weak hardware and boxes it can count, so a small one-look detector adapted to the real scene is the right trade.
12

Key takeaways

Seven sentences to remember; click any one for the reason behind it.
Each answer is a box (position and size), a class and a confidence. Section 01.
No separate region step, so it reaches 45 fps instead of seconds per photo. Section 04.
The cell that holds an object's centre is responsible for it; each cell guesses 2 boxes. Section 03.
30 = 2 boxes × 5 numbers + 20 class probabilities. Change the classes and only the 30 changes. Sections 04 and 09.
IoU = overlap ÷ union. Boxes that overlap a more confident box too much are dropped. Section 03.
Every layer size follows ⌊(N − K + 2P)/S⌋ + 1; parameters and multiply-adds are counted in sections 05, 06 and 08.
Freeze the backbone, resize the last layer to your classes, use a small learning rate, and test on real deployment photos. Sections 09 and 11.
13

Check your understanding

Five questions with instant feedback and an explanation for every answer; get four or more right and the stamp is yours.
0 / 5
■ STAMPED · YOLO BLUEPRINT · APPROVED
14

Glossary

Every term used on this page in plain words: type to filter, click a term to open its definition.