Part X — Computer Vision: CNNs, ResNets, Object Detection & Segmentation · Chapter 8

One-stage vs. two-stage detectors (YOLO vs. Faster R-CNN)

Hook

The last chapter scored a detection once it already existed. It never asked how a network decides, in the first place, which of the thousands of possible boxes in an image are even worth scoring. Two entirely different answers to that question became two families of detector — and the difference between them isn't just architecture, it's a straight speed-versus-precision trade.

Intuition

Six candidate boxes, one shared ground truth per box. Toggle between scoring every box in a single pass and scoring them through a cheap filter followed by a careful second look — watch which boxes get flagged as detected change.

Formalize

A one-stage detector (e.g. YOLO) evaluates every candidate box exactly once, in a single dense pass — fast, but every score shares whatever precision that one pass can afford. A two-stage detector (e.g. Faster R-CNN) runs a cheap region proposal pass over every box first, then spends a second, expensive classifier only on the boxes that clear a proposal threshold:

costone-stage=Ncfullvs.costtwo-stage=Ncproposal+Kcrefine\text{cost}_{\text{one-stage}} = N\cdot c_{\text{full}} \qquad\text{vs.}\qquad \text{cost}_{\text{two-stage}} = N\cdot c_{\text{proposal}} + K\cdot c_{\text{refine}}
  • NN — the total number of candidate boxes considered.
  • KK — the number of boxes that survive the proposal filter and reach the expensive second pass (KNK \le N).
  • cfullc_{\text{full}}, cproposalc_{\text{proposal}}, crefinec_{\text{refine}} — the compute cost of one one-stage evaluation, one cheap proposal, and one expensive refine, respectively.
  1. One-stage pays a flat cost for every box, once

    There's no filtering step — every one of the NN boxes gets the same single, cheap-per-box evaluation.

  2. Two-stage trades one expensive pass for two cheaper ones

    Even though crefinecfullc_{\text{refine}} \gg c_{\text{full}} per box, only KK boxes ever reach it — but when KK isn't small enough, or crefinec_{\text{refine}} is large enough, the total can still exceed one-stage's flat cost.

  3. The extra pass buys precision the coarse pass didn't have

    A box near the decision boundary can flip its final call depending on how much refinement it got — that's the accuracy two-stage is paying its extra compute for.

Play

The same six boxes, scored both ways side by side, plus the total compute each pipeline actually spent getting there. One box's final call depends on which pipeline scored it.

Worked example

Six boxes with true objectness confidence 0.92,0.77,0.47,0.18,0.84,0.560.92, 0.77, 0.47, 0.18, 0.84, 0.56 (boxes A–F), a detection threshold of 0.50.5:

  1. One-stage rounds every box onto a coarse 0.1 grid

    Box C's true confidence 0.470.47 rounds to 0.50.5 — right at the threshold, so one-stage calls it detected.

  2. Two-stage's proposal pass is coarser still, but only decides pass/fail

    On a 0.250.25 grid, 0.470.47 rounds to 0.50.5 too, clearing the 0.5\ge0.5 proposal threshold — so box C proceeds to the expensive second pass with its exact confidence, 0.470.47, restored.

  3. The refine pass flips the call

    0.47<0.50.47 < 0.5: two-stage calls box C not detected. One-stage and two-stage disagree on this one box — everywhere else, both pipelines agree.

  4. But two-stage still cost more overall

    Rounding every box's confidence to the nearest 0.250.25-grid value to check the 0.5\geq0.5 proposal threshold:

    • A: 0.921.00.92\to1.0, passes
    • B: 0.770.750.77\to0.75, passes
    • C: 0.470.50.47\to0.5, passes
    • D: 0.180.250.18\to0.25, fails
    • E: 0.840.750.84\to0.75, passes
    • F: 0.560.50.56\to0.5, passes

    Five of six boxes clear it, so K=5K=5. One-stage: 66 boxes ×1=6\times\,1 = 6 cost units. Two-stage: 6×0.2+5×3=1.2+15=16.26\times0.2 + 5\times3 = 1.2+15=16.2 — over 2.5×2.5\times the compute, entirely to correct one boundary case.

Checkpoint

Pick the one box where one-stage and two-stage disagree about whether it's detected.

Pick a box to try it
Summary
costone-stage=Ncfull,costtwo-stage=Ncproposal+Kcrefine\text{cost}_{\text{one-stage}} = N\cdot c_{\text{full}}, \qquad \text{cost}_{\text{two-stage}} = N\cdot c_{\text{proposal}} + K\cdot c_{\text{refine}}

One-stage detectors spend a fixed, cheap budget on every box and accept whatever precision that buys; two-stage detectors spend far more, but only on the boxes worth a second look, and can correct calls the coarse pass got wrong. Neither is strictly better — it's a speed-for-precision trade, tuned by how expensive a wrong call actually is. The next chapter moves from boxes to something finer-grained still: labeling every individual pixel.