Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Many small improvements, one fast detector
From 2020 on, YOLO became a family maintained by different teams, each version adding practical improvements:
- better data augmentation, for example gluing four images into one;
- better box losses that keep helping even when a guess misses the object entirely;
- better backbones and necks;
- removing hand-made pieces such as anchor boxes and, most recently, the duplicate-removal step.
The result is a detector that is easy to train on your own data and runs in real time on modest hardware.
Modern YOLO models are among the most widely deployed detectors in robotics, drones, agriculture and industrial inspection, because they are fast, accurate and come with simple training tools.
- 1. Mosaic augmentation glues…
- 2. Recent YOLOs removed…
- 3. A better box loss keeps helping when…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- IoU-based losses for a prediction p and target g:
- IoU loss: 1 − IoU, which is 1 for every non-overlapping pair, with zero gradient.
- GIoU = IoU − (C − U)/C, where C is the smallest enclosing box’s area and U the union. For two unit boxes 1 apart: 0 − (3 − 2)/3 = −1/3.
- DIoU = IoU − ρ²/c², where ρ is the centre distance and c the enclosing box’s diagonal. For the same pair: 0 − 4/10 = −0.4.
- CIoU = DIoU − αv, with v = (4/π²)(arctan(w_g/h_g) − arctan(w/h))², an aspect-ratio penalty.
- Mosaic: four images in one canvas, so each object’s area shrinks about 4-fold: more small objects and more context per batch.
- SPP block: max-pool the same map with kernels 5, 9 and 13 at stride 1 and concatenate with the input, so 512 channels become 2,048.
- 1. 1 − IoU for non-overlapping boxes:
- 2. GIoU ranges over…
- 3. SPP on 512 channels with 3 pools outputs:
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Modern YOLO in code
Exercise 1.
- GIoU, DIoU and CIoU equal 1 for identical boxes.
- For a box 2 units from a 2 × 2 target, GIoU was −1/3 and DIoU −0.4, while IoU was 0.
- Closer misses scored higher.
- CIoU penalised an aspect-ratio mismatch.
Practice.
- Ultralytics (
pip install ultralytics):YOLO("yolov8n.pt").train(data="my.yaml", epochs=100, imgsz=640)trains on your own data;- export to ONNX, TensorRT, CoreML or TFLite for deployment.
- Main ideas by version:
- YOLOv4: CSPDarknet53, SPP, PANet, Mosaic, CIoU, Mish.
- YOLOX: anchor-free decoupled head with SimOTA label assignment.
- YOLOv7: E-ELAN blocks and re-parameterisation, which merges branches at inference.
- YOLOv8: anchor-free decoupled head with a distribution focal loss for box edges.
- YOLOv10: “consistent dual assignments”, so no NMS is needed at inference.
- Model sizes: n, s, m, l and x trade speed for accuracy; nano models run on CPUs and small boards.
from ultralytics import YOLO
model = YOLO("yolov8n.pt") # 3.2 M parameters
model.train(data="drone_vehicles.yaml", epochs=100, imgsz=640)
results = model("frame.jpg") # boxes, classes, scores- 1. YOLOX's label assignment:
- 2. Re-parameterisation in YOLOv7…
- 3. YOLOv10 removes…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why IoU-based losses. Detection is judged by IoU, but L1/L2 losses on box coordinates treat errors independently of scale and shape. IoU is scale-invariant and matches the metric, but its gradient vanishes when boxes do not overlap. GIoU adds a term that keeps decreasing as the enclosing box tightens. DIoU instead penalises the normalised centre distance directly, which gives a consistent pull towards the target. CIoU adds aspect-ratio consistency.
What the simulation shows (exercise 2).
- DIoU and CIoU converged to higher overlap and were faster for boxes that already overlapped the target.
- GIoU moved non-overlapping boxes faster at first by enlarging them, a behaviour noted in the DIoU paper, but it ended lower.
- The DIoU paper reported DIoU faster overall in its simulation; the advantage depends on starting positions and step sizes.
Engineering versus science. YOLOv4’s “bag of freebies” are training-time changes that cost nothing at inference; the “bag of specials” add a little inference cost for accuracy. Many components were chosen by ablation on COCO and do not generalise uniformly, so they should be re-checked on new data.
Anchor-free and NMS-free.
- Anchor-free heads (YOLOX, YOLOv8) remove anchor tuning (E9-8, E9-11).
- Dynamic assignment (SimOTA, TAL) chooses positives by a cost combining classification and IoU.
- One-to-one assignment (YOLOv10, DETR) removes duplicate predictions, and with them NMS (E9-14).
- 1. Plain IoU loss fails when boxes…
- 2. 'Bag of freebies' means…
- 3. One-to-one assignment removes the need for…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Which box loss converges best?
History.
- H. Rezatofighi et al. (2019) introduced GIoU at CVPR.
- Z. Zheng et al. (2020) introduced DIoU and CIoU at AAAI.
- A. Bochkovskiy, C.-Y. Wang and H.-Y. M. Liao (2020) published YOLOv4 (43.5% COCO AP at about 65 fps on a V100).
- Z. Ge et al. (2021) introduced YOLOX; C.-Y. Wang, A. Bochkovskiy and H.-Y. M. Liao (2022) YOLOv7; A. Wang et al. (2024) YOLOv10.
- YOLOv5 and YOLOv8 (Ultralytics) were released as software without papers.
Exercise 2. 300 boxes start within 3 units of a 1 × 1 target, with random sizes and aspect ratios; only 32% overlap it at the start. Each is regressed by gradient descent on one loss:
| loss | mean IoU after 50 steps | started overlapping | started apart | after 400 steps |
|---|---|---|---|---|
| IoU | 0.243 | 0.767 | 0.000 | 0.259 |
| GIoU | 0.506 | 0.777 | 0.381 | 0.836 |
| DIoU | 0.454 | 0.810 | 0.288 | 0.908 |
| CIoU | 0.458 | 0.823 | 0.288 | 0.907 |
- Plain IoU leaves non-overlapping boxes stuck. Their IoU stays 0 because the gradient is 0.
- DIoU and CIoU reach the highest final overlap, and are faster for boxes that already overlap.
- GIoU is faster for distant boxes at first, because it enlarges them more: their mean area grew from 0.91 to 1.76 in 50 steps, against 1.55 with DIoU. It then converges more slowly.
- CIoU’s aspect term changed little here, because sizes were also free to change.
Modern YOLO in AI, robotics and aerospace
- Robotics and drones: YOLOv5/v8 nano and small models run on Jetson boards and other embedded devices for real-time detection.
- Agriculture and inspection: custom-trained YOLO detects crops, weeds, defects and wildlife from drone imagery.
- Deployment: export to TensorRT or TFLite and quantise. Check that accuracy holds after quantisation on the target device.
References
- A. Bochkovskiy, C.-Y. Wang, H.-Y. M. Liao (2020). “YOLOv4: optimal speed and accuracy of object detection.” arXiv:2004.10934.
- H. Rezatofighi et al. (2019). “Generalized intersection over union: a metric and a loss for bounding box regression.” Proc. CVPR.
- Z. Zheng et al. (2020). “Distance-IoU loss: faster and better learning for bounding box regression.” Proc. AAAI.
- Z. Ge, S. Liu, F. Wang, Z. Li, J. Sun (2021). “YOLOX: exceeding YOLO series in 2021.” arXiv:2107.08430.
- A. Wang et al. (2024). “YOLOv10: real-time end-to-end object detection.” Advances in NeurIPS.