Paper commentary
Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression
Generalized IoU gives box regression a loss that still learns without overlap
- Problem IoU is zero for non-overlapping boxes, so its gradient vanishes and it cannot guide regression there. Common distance losses also don't match IoU, the metric detectors are judged by.
- Method GIoU subtracts from IoU the share of the smallest enclosing box that neither object covers. This keeps a signal that changes with placement even when boxes don't overlap, and it can be used as both metric and loss.
- Results YOLO v3 with the GIoU loss scored .477 IoU-based AP, compared to .461 for MSE on PASCAL VOC 2007.
Why IoU can't drive regression on its own
Box regression is usually trained with l1 or l2 norm losses on the box parameters, yet detections are judged by IoU. These two objectives don't line up, so a lower norm loss doesn't guarantee better overlap. Figure 1 makes this concrete: the l2 distance between corners is fixed at 8.41, yet the IoU values are 0.26, 0.49 and 0.65. Because the distance is identical in all three cases, the loss cannot separate them, while IoU clearly does.
IoU is a sound measure: it is scale invariant and it is the yardstick every benchmark uses. Its weakness appears when boxes don't overlap, because the intersection is then zero and so is IoU. The gradient is zero in that region too, so an IoU loss can't pull a predicted box toward its target. The authors therefore ask whether an overlap measure that stays informative without overlap can serve as both the metric and the training loss.
Extending IoU with an empty-area penalty
The key idea is to keep IoU and subtract the share of a shared enclosing shape that neither object covers. The enclosing shape C is the smallest convex shape containing both A and B, and for boxes it is the smallest box that contains both. Where IoU stops at zero for distant shapes, this empty-area fraction still changes with their placement.
The paper writes the measure as follows. \[ \mathrm{GIoU} = \mathrm{IoU} - \frac{|C \setminus (A \cup B)|}{|C|} \]
GIoU is always a lower bound on IoU, and that bound gets tighter as A and B become more similar and closer. Its range is symmetric, from -1 to 1, while IoU runs only from 0 to 1. It stays invariant to the scale of the problem, and its distance form 1 minus GIoU satisfies the usual metric properties.
Turning GIoU into a bounded regression loss
For two axis-aligned boxes, the intersection and the smallest enclosing box are both rectangles, so no general geometry is needed. Their corners are picked from the two boxes' coordinates with min and max, and an overlap check decides whether an intersection exists. Algorithm 2 lists these steps for a predicted box and a ground truth box.
The predicted corners are first ordered with min and max, so the box has positive width and height. The areas of the ground truth box, the predicted box and their intersection then give the union U as Ap + Ag − I. IoU is I divided by U, and the enclosing box area Ac gives the penalty term (Ac − U) divided by Ac. Substituting into 1 minus GIoU gives the loss the detector minimizes.
\[ \mathcal{L}_{GIoU} = 1 - \mathrm{IoU} + \frac{A_c - U}{A_c} \]
Min, max and piecewise linear operations have well-defined derivatives, so the loss can be backpropagated. The GIoU loss has a gradient in every case, including non-overlapping boxes, where IoU loss stalls. The enclosing area Ac is at least the union U, so the penalty stays positive and bounded. Overall the loss lies between 0 and 2 for any predicted box.
When the boxes don't overlap, the loss reduces to 2 minus U divided by Ac, so minimizing it maximizes U divided by Ac. The authors note that this pushes the predicted box toward overlap. Over more than 10K random pairs of 2D rectangles, GIoU tracks IoU closely at high overlap, and below IoU of 0.2 it changes more steeply. The authors take this steeper slope as the reason the GIoU loss can be a better choice than the IoU loss.
YOLO v3 results
YOLO v3 was trained from its Darknet code with the MSE box loss swapped for the IoU or GIoU loss. The classification loss kept its MSE form, and the new box loss was regularized against it with only minimal tuning. On PASCAL VOC 2007 the models trained for up to 50K iterations on the training and validation sets.
On the PASCAL VOC 2007 test set, YOLO v3 trained with the GIoU loss scored an IoU-based AP of .477, compared to .461 for its MSE baseline. The IoU loss gave .466 under the same setup. So the GIoU loss gives a larger gain than the IoU loss, and both beat the MSE baseline on the IoU measure.
On the MS COCO 2018 test set, YOLO v3 trained with the GIoU loss scored .333 IoU-based AP, compared to .314 for MSE. AP75 went from .333 with MSE to .362 with GIoU under the same comparison. The COCO runs trained on the 2014 training set and 88% of the validation set for up to 502k iterations. The authors describe the result as a consistent improvement, in line with the VOC run.
Faster R-CNN and Mask R-CNN results
For these detectors the authors replaced the l1-smooth loss in the final box refinement stage with the IoU or GIoU loss. They multiplied the IoU and GIoU losses by a factor of 10 in all experiments.
On the PASCAL VOC 2007 test set, Faster R-CNN with the GIoU loss scored an IoU-based AP of .392, compared to .370 for l1-smooth. On the IoU-based AP75 measure it went from .358 with l1-smooth to .404 with GIoU. The IoU loss improved on l1-smooth as well, but by less than GIoU did.
Mask R-CNN was trained on the MS COCO 2018 training set for 95K iterations. On the MS COCO 2018 test set, Mask R-CNN with the GIoU loss scored an IoU-based AP of .377, compared to .368 for l1-smooth. Its AP75 went from .399 with l1-smooth to .409 with GIoU.
The gain is smaller than the one for YOLO v3. The authors suggest that the anchor boxes on these detectors are denser, so cases where GIoU beats IoU, such as non-overlapping boxes, come up less often. They also point to the regularization parameter, which was tuned on PASCAL VOC and may be sub-optimal on MS COCO.
Limitations
The weighting between the box loss and the classification loss was set with only minimal tuning. As a result, YOLO v3's classification scores may fall below the baseline, which the authors expect to limit its AP. The authors expect AP to improve with a better search over these regularization parameters.
For Faster R-CNN and Mask R-CNN the factor of 10 was applied to every experiment without a reported search. The authors judge the PASCAL VOC tuning sub-optimal on MS COCO.
COCO 2018 test results were reported only for IoU-based AP, so GIoU-based scores exist only on validation data. Each setting appears as a single value in the tables, and no spread across runs is reported.
The analytical form covers only axis-aligned 2D boxes.
Paper info
- Authors
- Hamid Rezatofighi, Nathan Tsoi, JunYoung Gwak, Amir Sadeghian, Ian Reid, Silvio Savarese
- Venue
- arXiv · Preprint
- First published
- 2019-2-25
- Added
- 2026-11-11
- Updated
- 2019-4-15
- Version
- v2
- arXiv
- 1902.09630
- Category
- cs.CV · cs.AI · cs.LG
- Original paper terms
- CC BY-NC-SA 4.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Hamid Rezatofighi, Nathan Tsoi, JunYoung Gwak, Amir Sadeghian, Ian Reid, Silvio Savarese (2019). Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression. arXiv:1902.09630v2. https://arxiv.org/abs/1902.09630v2
BibTeX
@misc{rezatofighi2019generalized,
title = {{Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression}},
author = {Hamid Rezatofighi and Nathan Tsoi and JunYoung Gwak and Amir Sadeghian and Ian Reid and Silvio Savarese},
year = {2019},
eprint = {1902.09630},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1902.09630v2}
}