Topic · Mechanisms

Loss functions

Everything on this site about loss functions, in the order to read it: a page is listed after the pages it builds on. The figures below are the ones those pages use to explain it; each is live: move a slider and it recomputes.

In reading order

  1. Read
  2. Read
  3. Paper
  4. Paper
  5. Paper

The figures these pages use

Pulled from the pages above. Move a slider and the figure recomputes, exactly as on its page.

From Object Detection — A Quick Read › Literature Survey

1.0
MSE, MAE and Huber loss. Huber follows the squared loss near zero and the absolute loss far from it, so one large error cannot dominate.

From Object Detection — A Quick Read › Literature Survey

0.5
Cross-entropy for y = 1 and y = 0. Left: a foreground example. Right: a background example. Even a confident, correct prediction still carries some loss.

From Object Detection — A Quick Read › Literature Survey

121.0
Intersection over Union. The dashed box is the ground truth, the solid box is the prediction, and the shaded area is their overlap.

From Understanding Focal Loss —A Quick Read › Focal Loss

0.8
From p to p_t. Whatever the label, p_t is 'how right the model was'. A large p_t is an easy example.

From Understanding Focal Loss —A Quick Read › Focal Loss

0.25
α-balanced cross-entropy. α scales the foreground curve and 1 − α the background curve. It changes how much each class counts, not which examples are hard.

From Understanding Focal Loss —A Quick Read › Focal Loss

2.0
The modulating factor (1 − p_t)^γ. γ = 0 is plain cross-entropy. As γ grows, everything to the right of p_t ≈ 0.5 is pushed towards zero.

From Understanding Focal Loss —A Quick Read › Focal Loss

4.00.25
Focal loss for y = 1 and y = 0. Left: a foreground example. Right: a background example. A larger γ flattens the side where the model is already right.

From Understanding Focal Loss —A Quick Read › Focal Loss

2.00.25
Focal loss and cross-entropy. Loss for a positive example as the model grows confident. The dashed line is cross-entropy.

From IoU Losses — From 1 − IoU to the 2026 Variants, One Box at a Time › 3. Why ℓ1, ℓ2 and Smooth-ℓ1 Disagree with IoU

0
Same corner distance, different IoU. The dashed rust square is the ground truth. The blue prediction keeps its top-left corner exact; its bottom-right corner rides the faint circle, always 2 units from the true corner, so the ℓ2 distance of the corners never changes. Watch IoU and GIoU swing anyway. Try this: press play, or drag the blue corner round the circle; then switch to × 10 and see ℓ2 jump while IoU and GIoU stay put.

From IoU Losses — From 1 − IoU to the 2026 Variants, One Box at a Time › 4. The IoU Loss — UnitBox's −ln IoU and the Plain 1 − IoU

The classic five box losses on two boxes you drag. The dashed box is the ground truth, the solid one the prediction. Drag a centre to move a box, its bottom-right corner to resize it, and pick a loss. The small plot slides the prediction along the line through both centres. Try this: pull the prediction clear of the ground truth with 1 − IoU picked, and watch the loss sit at 1.0000 wherever you leave it.

From IoU Losses — From 1 − IoU to the 2026 Variants, One Box at a Time › 7. CIoU — Add the Aspect Ratio

12
CIoU's aspect-ratio term, with the two choices of α. The dashed box is the ground truth (2 × 1), the solid one the prediction, both on the same centre. Change the prediction's width and height with the sliders or by dragging its right and bottom edges. Try this: turn on the journal α at the crossed box and the aspect term vanishes; then set the width and the height to 1.5 (IoU 0.5455) and it comes back.

From IoU Losses — From 1 − IoU to the 2026 Variants, One Box at a Time › 8. DIoU-NMS, Briefly

140.5
Keep or suppress, by DIoU. The dashed box M is the one already kept. Slide the candidate Bᵢ across it: ordinary NMS looks only at IoU, DIoU-NMS also asks how far apart the centres are.

From IoU Losses — From 1 − IoU to the 2026 Variants, One Box at a Time › 9. 2021–2022: Width and Height, Powers, and Angles

1 / 13 · EIoU
The 2021–2025 box losses on two boxes you drag. Same boxes and handles as the classic five: drag a centre to move a box, its bottom-right corner to resize it, and step through the losses. Each one runs at its default (the paper's, or the released code's where the paper gives none), named under its value. Try this: pick Focal-EIoU and pull the prediction clear of the ground truth; the loss drops to 0.0000.

From IoU Losses — From 1 − IoU to the 2026 Variants, One Box at a Time › 9. 2021–2022: Width and Height, Powers, and Angles

1 / 5 · α-IoU0.9
α-IoU
3
Focal-EIoU
0.5
WIoU v3
1.931
PIoU v2
1.30.61
Focaler-IoU
00.95
Which boxes get the gradient: five re-weightings. Step through the five curves. Each has its own folded panel of knobs (α-IoU, Focal-EIoU, WIoU v3, PIoU v2, Focaler-IoU); the IoU slider places the marker for α-IoU, Focal-EIoU and Focaler-IoU, β and P place it for the other two. Try this: on α-IoU, slide α from 1 to 3 and watch the gradient move from poor boxes to good ones.

From IoU Losses — From 1 − IoU to the 2026 Variants, One Box at a Time › 10. 2023–2024: Weights, Corners and Helper Boxes

0.85
Inner-IoU's helper boxes: where the gradient goes. Two boxes 10 units wide, their centres s apart, and the helper boxes Inner-IoU scores instead (dashed grey). The plot is how steeply the helper IoU changes with s, for ratio 0.8, 1 (the real boxes), 1.2 and yours. Try this: play the offset and watch the 0.8 curve drop to 0 at s = 8, where the real boxes still overlap.

From IoU Losses — From 1 − IoU to the 2026 Variants, One Box at a Time › 12. IoU Beyond the Axis-Aligned Box

8301
Tiny boxes and turned boxes: where IoU needs help. Tiny objects: the dashed square is the ground truth, the solid one the same square shifted by 2 px right and 2 px down; change its side. Rotated boxes: the solid box is the dashed one turned about its centre, and the ellipses are the Gaussians each box becomes. Try this: turn a square and watch ProbIoU stay at 1.0000, then stretch the box.

From IoU Losses — From 1 − IoU to the 2026 Variants, One Box at a Time › 12. IoU Beyond the Axis-Aligned Box

5.3
A box side as a distribution over bins. Each bar is the predicted probability of one bin; the side is read off as their average, weighted by the bars. The dashed line is the true distance, the dot the value the bars decode to. Try this: switch to the D-FINE bins and see how they crowd around zero, or drag the dashed line.

From IoU Losses — From 1 − IoU to the 2026 Variants, One Box at a Time › 14. Which One Should You Use?

Every box loss on the pair you drag. One row per loss, in the read's order: its value on these boxes and what one gradient step does to the blue prediction. Steps follow each loss's formula (PIoU's as in its authors' code), holding fixed CIoU's α (as its released code), Focal-EIoU's weight (our choice), WIoU's enclosing box (its paper). Try this: pull the blue box clear of the dashed one and count the rows that say "no signal".

Tags that go with it

Object detection 5Re-identification 2Class imbalance 1Data augmentation 1Evaluation and metrics 1Faces 1Non-maximum suppression 1Training recipes 1