Computer Vision

Object Detection: R-CNN to YOLO

Identifying what objects are in an image and predicting their exact 2D bounding box locations.

🔴 advanced5 min readvision
Object Detection combines image classification (identifying category labels) and localization (predicting bounding box coordinates [x_center, y_center, width, height]). Key components include Backbone feature extractors (ResNet, CSPDarknet), Feature Pyramid Networks (FPN) for multi-scale object detection, Bounding Box Regression loss (CIoU / GIoU), and Non-Maximum Suppression (NMS) to eliminate duplicate overlapping predicted boxes.

What is Object Detection?

While Image Classification assigns a single label to an entire image ("Dog"), Object Detection predicts category labels AND bounding boxes for multiple objects in the image:

  IMAGE CLASSIFICATION                          OBJECT DETECTION
  Input: Image ──► Output: "Dog"                Input: Image ──► Output:
                                                                 - Dog: [x=120, y=80, w=200, h=150]
                                                                 - Cat: [x=350, y=40, w=100, h=90]

Bounding Box Parameterization

A predicted bounding box $b$ is represented as a 4-dimensional vector:

b = [ x_center, y_center, width, height ]

Coordinates are normalized relative to image dimensions ($[0, 1]$ interval).

The Object Detection System Pipeline

  Input Image ──► [ Backbone (ResNet) ] ──► [ Feature Pyramid Network (FPN) ] ──► [ Detection Head ]
                                                                                   ├── Class Scores
                                                                                   ├── Bounding Boxes
                                                                                   └── Objectness Score
  1. Backbone: Pre-trained CNN (ResNet, DarkNet) or Vision Transformer extracting deep feature maps.
  2. Neck (Feature Pyramid Network - FPN): Combines multi-scale feature maps so small objects are detected on high-resolution layers, while large objects are detected on deep semantic layers.
  3. Head: Predicts classification probabilities, bounding box regression offsets, and objectness presence scores.

Bounding Box Loss Functions

Early detectors used Smooth $L_1$ loss independently on $x, y, w, h$.

Modern detectors use IoU-based losses that treat the 4 coordinates as a unified 2D box:

  1. GIoU (Generalized IoU): Adds a penalty for the area of the smallest enclosing box covering both prediction and ground truth, resolving zero-gradient issues when boxes do not overlap.
  2. DIoU (Distance IoU): Penalizes center point distance $|b - b^{\text{gt}}|_2^2$ to accelerate box alignment.
  3. CIoU (Complete IoU): Considers overlap area, center point distance, AND aspect ratio consistency.

Say this out loud

Object detection predicts both object category labels and 4D bounding box coordinates [x, y, w, h]. Architectures combine a Backbone for feature extraction, a Feature Pyramid Network (FPN) to merge multi-scale feature maps for detecting small and large objects, and a Detection Head optimizing multi-task loss (Focal Loss for classification + CIoU Loss for bounding box regression).

Follow-ups to expect

Check yourself

Question 1 of 3

What are the four bounding box coordinate outputs predicted by an object detection model?

More in Computer Vision

See all →
Image Augmentation Strategies5 minResizing, Normalization & Colour Spaces4 minResNet, EfficientNet & Friends5 min