Fast Object Detection Networks

Computer Vision · v1.0.15

2026-10-20 14:07:47

Where we are

Where this fits

  • The region-based family ends with Faster R-CNN: a shared backbone, a learned Region Proposal Network, RoI pooling and a multi-task loss
  • Proposals are almost free there, but the second stage is not: a small network still runs once per region
  • The fastest reported Faster R-CNN configuration reaches about 7 frames per second

The detectors in this unit remove the second stage: one network, evaluated once, at 45 to 155 frames per second.

Outline of key topics

  1. YOLO — detection as one regression over a grid, its loss, and its error profile
  2. SSD — default boxes over feature maps of several resolutions, and how its training is stabilised
  3. YOLOv2 — the increments that answer YOLO’s weaknesses
  4. Choosing a detector — stages, input resolution and object scale

YOLO’s unified detection

Two pipelines

Separately trained components are “slow and hard to optimize”; one network is optimised end to end.

Grid-based prediction

\(7 \times 7 \times 30\) output tensor for PASCAL VOC.

  • the cell holding an object’s centre is responsible for it
  • each cell predicts \(B\) boxes: \(x, y, w, h\) and a confidence
  • each cell also predicts \(C\) class probabilities, shared by its \(B\) boxes
  • output tensor: \(S \times S \times (B \times 5 + C)\)

Box parameterisation and confidence

Coordinates

  • \((x, y)\): box centre relative to its cell, in \([0, 1]\)
  • \((w, h)\): relative to the whole image, in \([0, 1]\)

Confidence

\[\Pr(\text{Object}) \times \mathrm{IOU}^{\text{truth}}_{\text{pred}}\]

  • no object in the cell: target 0
  • otherwise the IoU of the predicted box with the ground truth

Class-specific score at test time

\[\Pr(\text{Class}_i \mid \text{Object}) \times \Pr(\text{Object}) \times \mathrm{IOU}^{\text{truth}}_{\text{pred}}\]

The YOLO network

Convolutional layers extract features; the fully connected layers predict probabilities and coordinates.

Architecture details

Alternating \(1 \times 1\) convolutional layers reduce the feature space from the preceding layers.
  • inspired by GoogLeNet, with alternating \(1 \times 1\) and \(3 \times 3\) layers in place of inception modules
  • Fast YOLO: 9 convolutional layers instead of 24, fewer filters
  • the network sees the whole image, so it encodes context about classes

The YOLO loss and inference

Two mismatches handled by hand

Class imbalance

  • most cells contain no object, and their confidence targets of zero overpower the cells that do
  • two weights restore the balance:

\[\lambda_{\text{coord}} = 5, \qquad \lambda_{\text{noobj}} = 0.5\]

Scale

  • a small error in a large box matters less than in a small one
  • widths and heights enter as square roots:

\[\left(\sqrt{w} - \sqrt{\hat{w}}\right)^2\]

The multi-part detection loss \(^1/_2\)

\[ \begin{align} &\lambda_{\text{coord}} \sum_{i,j} \mathbb{1}^{\text{obj}}_{ij} \left[ (x_i - \hat{x}_i)^2 + (y_i - \hat{y}_i)^2 \right] \\ +\ &\lambda_{\text{coord}} \sum_{i,j} \mathbb{1}^{\text{obj}}_{ij} \left[ \left(\sqrt{w_i} - \sqrt{\hat{w}_i}\right)^2 + \left(\sqrt{h_i} - \sqrt{\hat{h}_i}\right)^2 \right] \end{align} \]

  • the centre term, then the size term
  • \(i\) runs over the \(S^2\) cells and \(j\) over the \(B\) boxes of a cell

The multi-part detection loss \(^2/_2\)

\[ \begin{align} +\ &\sum_{i,j} \mathbb{1}^{\text{obj}}_{ij} \left(C_i - \hat{C}_i\right)^2 + \lambda_{\text{noobj}} \sum_{i,j} \mathbb{1}^{\text{noobj}}_{ij} \left(C_i - \hat{C}_i\right)^2 \\ +\ &\sum_{i} \mathbb{1}^{\text{obj}}_{i} \sum_{c} \left(p_i(c) - \hat{p}_i(c)\right)^2 \end{align} \]

  • the confidence term, for boxes with and without an object
  • the class term, only for cells that contain an object

The responsible predictor

IoU is computed from the boxes drawn; the highest one is responsible.

  • several predictors per cell, one responsible for each object
  • the one with the highest current IoU is assigned
  • the predictors specialise in sizes, aspect ratios or classes, improving recall
  • classification error is penalised only where an object is present
  • coordinate error is penalised only for the responsible predictor

Training and inference

Training

  1. pretrain the first 20 convolutional layers on ImageNet at \(224 \times 224\) (88% top-5)
  2. add 4 convolutional and 2 fully connected layers, raise the input to \(448 \times 448\)
  3. train about 135 epochs on VOC 2007 and 2012, leaky ReLU activation

\[\phi(x) = \begin{cases} x, & x > 0 \\ 0.1x, & \text{otherwise} \end{cases}\]

Inference

  • one forward pass
  • \(7 \times 7 \times 2 = 98\) boxes per image
  • non-maximal suppression adds 2–3% mAP, and matters less here than for R-CNN or DPM

What YOLO gets wrong

Where YOLO stands against Faster R-CNN

  • YOLO runs several times faster than Faster R-CNN, and scores somewhat lower
  • Fast YOLO is faster again, and gives up more accuracy for it
  • both are well above the frame rate any two-stage detector of the period reaches

Error profiles: YOLO against Fast R-CNN

  • YOLO: far fewer background errors
  • YOLO: more localisation errors than all other sources combined
  • the two profiles are close to complementary

Combining the two detectors

  • YOLO rescores every Fast R-CNN box that has a similar YOLO box
  • best Fast R-CNN: 71.8% to 75.0% mAP, a gain of 3.2 points
  • ensembling Fast R-CNN with itself gains only 0.3 to 0.6 points

The gain comes from complementary error profiles, not from averaging.

Structural limits

  • Spatial constraints: flocks of small objects fail
  • Coarse features: unusual aspect ratios generalise poorly
  • Approximate loss: small and large box errors treated alike

Domain transfer

  • trained on natural images, tested on artwork
  • R-CNN drops sharply: Selective Search is tuned to natural images
  • YOLO models object size, shape and the relations between objects

SSD: default boxes across scales

SSD against YOLO

Auxiliary feature layers decrease in size progressively and each one feeds a predictor.

Convolutional predictors

  • a small kernel yields a class score or a shape offset at every location
  • \(k\) default boxes per location, \(c\) classes
  • outputs for an \(m \times n\) map:

\[(c + 4)\,k\,m\,n\] - replaces YOLO’s fully connected head

Default boxes

  • a fixed set of reference boxes per feature map cell, tiled convolutionally; every offset is relative to one of them
  • a large object is matched on a coarse map and a small one on a fine map

Scales and aspect ratios

\[s_k = s_{\min} + \frac{s_{\max} - s_{\min}}{m - 1}(k - 1)\]

\[w_k^a = s_k \sqrt{a_r}, \qquad h_k^a = \frac{s_k}{\sqrt{a_r}}\]

  • \(a_r \in \{1, 2, 3, \tfrac12, \tfrac13\}\)
  • for \(a_r = 1\) a further box of scale \(s'_k = \sqrt{s_k s_{k+1}}\)
  • 6 default boxes per location

Matching ground truth to default boxes

  1. each ground-truth box takes its best default box
  2. then every default box with overlap above 0.5 is matched too
  • several overlapping default boxes may score high, rather than one being required

The SSD objective

\[L(x, c, l, g) = \frac{1}{N}\left(L_{conf}(x, c) + \alpha\, L_{loc}(x, l, g)\right)\]

Localisation: smooth \(L_1\)

  • offsets for the centre \((cx, cy)\) of the default box \(d\)
  • \(\hat{g}^{w}_j = \log\!\left(g^w_j / d^w_i\right)\), likewise the height

Confidence and weights

  • softmax loss over class confidences
  • \(N\) matched default boxes; the loss is 0 if \(N = 0\)
  • \(\alpha = 1\) by cross validation

Making single-shot training work

Hard negative mining

Schematic: 4 positives, 12 negatives kept.

  • after matching, most default boxes are negatives
  • sort negatives by confidence loss and keep the top ones
  • negative to positive ratio at most 3:1
  • faster optimisation and more stable training

Data augmentation

Each training image is sampled by one of three options:

  • the entire original image
  • a patch with minimum Jaccard overlap 0.1, 0.3, 0.5, 0.7 or 0.9
  • a random patch
  • patch size in \([0.1, 1]\) of the image, aspect ratio between \(\tfrac12\) and 2
  • resized, flipped with probability 0.5, photometrically distorted

Random crops act as a zoom in.

Zoom-out augmentation

  • the image is placed on a mean-filled canvas of \(16\times\) the original size
  • training iterations are doubled
  • a consistent 2–3% mAP, almost entirely on small objects
  • SSD300 on VOC 2007: 74.3% from 77.2%

Ablations at \(300 \times 300\)

Table of ablations

  • augmentation: 65.5% to 74.3%, the largest single gain
  • dropping the \(\tfrac13\) and 3 ratios: −0.6; dropping \(\tfrac12\) and 2 as well: −2.1 more
  • atrous VGG-16: same accuracy, about 20% faster

Number of prediction layers

  • mAP falls from 74.3% with six layers to 62.4% with conv7 alone
  • box count is held near 8732 throughout

The number of resolutions, not the number of boxes, carries the accuracy.

SSD results and runtime

Where SSD stands

Relative standing on VOC 2007.

  • SSD overtakes Faster R-CNN on accuracy while staying far faster, which YOLO does not manage
  • the larger input makes SSD more accurate again, at a cost in speed
  • input resolution is the main knob: the two SSD models differ only in input size

Where SSD errs

Sensitivity to bounding-box area, from extra-small to extra-large, per category.
  • recall about 85–90% under the weak criterion
  • less localisation error than R-CNN: boxes are regressed directly
  • more confusion between similar classes, as locations are shared across categories
  • small objects are much worse: they may carry no information at the top layers

SSD on COCO

  • the default boxes are made smaller, because COCO’s objects are smaller than PASCAL’s
  • SSD scores above Faster R-CNN, and its margin is wider at the stricter overlap threshold
  • the gain is large on big objects
  • on small objects it is slight: a coarse top layer carries little signal about them

Runtime

Share of the forward time.

  • confidence threshold 0.01, then NMS at 0.45 per class, top 200 kept: 1.7 ms per image
  • SSD300: 46 frames per second at batch size 1, evaluating 8732 boxes
  • SSD512: 19 frames per second on 24564 boxes

SSD300 is the first real-time method above 70% mAP.

Key innovations of YOLOv2

The increments

  1. batch normalisation on every convolution, and dropout removed
  2. high-resolution classifier: fine-tune at \(448 \times 448\) before detection
  3. anchor boxes in place of the fully connected head: a large gain in recall
  4. dimension clusters and direct location prediction: the largest single step
  5. passthrough features from a \(26 \times 26\) map, for smaller objects
  6. multi-scale training: a new input size every 10 batches

Priors from data, centres kept in the cell

Dimension clusters

\[d(\text{box}, \text{centroid}) = 1 - \mathrm{IOU}(\text{box}, \text{centroid})\]

  • 5 clustered priors match the data as well as 9 hand-picked anchors

Direct location prediction

\[b_x = \sigma(t_x) + c_x, \qquad b_w = p_w e^{t_w}\]

  • unconstrained offsets let any anchor land anywhere, and take long to stabilise

A backbone built for the budget

  • Darknet-19: 19 convolutional and 5 maxpooling layers, 72.9% top-1 on ImageNet
  • mostly \(3 \times 3\) filters, \(1 \times 1\) compression between them, global average pooling
  • the backbone is about 80% of the forward pass in these systems

Detection throughput is a backbone design problem before it is a head design problem.

Choosing a detector

The four detectors side by side

  • Faster R-CNN is accurate and by far the slowest: a second stage runs once per region
  • YOLO trades accuracy for a large gain in speed
  • SSD and YOLOv2 recover the accuracy and keep most of the speed

What moves a detector on that plot

Stages

  • dropping the second stage moves a detector far to the right, and down
  • SSD and YOLOv2 show the drop in accuracy is not intrinsic to having one stage

Input resolution

  • the main knob within one architecture, and the most expensive: up and to the left

Object scale

  • predicting from one coarse map leaves little signal about small objects
  • predicting from several resolutions is what SSD’s prediction layers buy, and the cheapest of the three
  • SSD gains far more on large objects than on small ones

Object size decides between resolution and multi-scale features.

Summary

Summary

  • One regression from pixels to boxes, evaluated once
  • Responsible predictor and matching replace proposals
  • Hard negative mining against the background
  • Priors from data, with a bounded centre
  • Several resolutions, not more boxes, carry the accuracy
  • Backbone first: about 80% of the forward pass