YOLO Concept
YOLO (You Only Look Once) is the most influential real-time object detection framework. Understanding its key innovation helps you appreciate how modern detection works.
What Makes YOLO Different
Before YOLO (2015), object detectors worked in two stages:
1. Region proposal: find candidate regions that might contain objects
2. Classification: classify each region separately
This two-stage approach was slow — unsuitable for real-time applications.
YOLO's innovation: do everything in ONE pass.
- Divide the image into a grid
- For each grid cell, predict: bounding boxes + confidence + class probabilities
- Process the entire image in a single forward pass through the neural network
- Result: detection in ~25ms — fast enough for 40 FPS real-time processing
YOLO versions: YOLOv1 (2015), v2, v3, v4, YOLOv5 (by Ultralytics), YOLOv8 (current standard)
YOLOv8 is trained on COCO dataset: 80 classes including person, car, bicycle, dog, cat, bottle, chair, and many more.
Machine Learning follows a structured pipeline from data to deployment
YOLO Grid Concept
# YOLO conceptual explanation (simplified)
# YOLO divides the image into a grid (e.g., 13x13 or 52x52)
# Each grid cell is responsible for detecting objects
# whose centre falls within that cell
grid_size = 13 # Simplified: 13x13 grid
image_size = 416 # Typical YOLO input size
cell_size = image_size / grid_size
print(f"Each grid cell covers: {cell_size:.0f}x{cell_size:.0f} pixels")
print(f"Total cells: {grid_size * grid_size}")
# For each cell, YOLO predicts:
# - B anchor boxes (typically 3), each with:
# - (cx, cy): centre of bounding box (relative to cell)
# - (w, h): width/height of bounding box
# - objectness_score: probability an object is here
# - class_probabilities: [P(person), P(car), P(dog), ...]
# Final score = objectness_score × class_probability
# Only detections above confidence_threshold are kept
# Non-Maximum Suppression (NMS) removes duplicate boxes:
# If two boxes overlap significantly (IoU > threshold)
# and detect the same class, keep only the highest-confidence one
print("\nYOLO key points:")
print("1. Single forward pass — very fast")
print("2. Grid-based: each cell detects objects centred within it")
print("3. NMS removes duplicate overlapping boxes")
print("4. Trained on 80 COCO classes")