liveBook · Manning

Intersection over Union

As explained in Math and Architectures of Deep Learning

A bounding-box overlap metric used to match proposed regions to ground-truth boxes.

Intersection over Union (IoU) measures how much two bounding boxes overlap. For boxes A and B, IoU = area(A ∩ B) / area(A ∪ B). The score is high when the boxes nearly coincide: their shared area is large and their combined area is not much larger. It is low when they differ substantially, because little area is shared. section 11.4.2

Figure 11.15 section of the two areas divided by the union of the two areas.

The intersection is the shared portion of the boxes; the union is every area covered by either box. Dividing the former by the latter turns geometric agreement into one overlap score. section 11.4.2

In a region proposal network, IoU matches each anchor box against ground-truth (GT) object boxes. This determines which anchors should learn that an object is present and which should represent background. An anchor with the greatest IoU for a GT box is positive, even if its score is otherwise small. Anchors with IoU greater than 0.7 are also positive; non-positive anchors with IoU below 0.3 for every GT box are negative. Anchors between those cases are ignored by the training objective. section 11.4.2

IoU supports two distinct decisions in Faster R-CNN-style detection:

  • Match GT boxes to anchors for classifier labels and bounding-box regression targets. One object can make multiple anchors positive. section 11.4.2
  • Remove duplicate predicted detections with non-maximal suppression (NMS): retain the highest-confidence box, then discard remaining boxes whose IoU with it exceeds a threshold. section 11.4.2

Anchor assignment with IoU

For every valid anchor, compute its IoU against every GT box. A tensor operation such as torchvision.ops.box_iou produces the GT-by-anchor score matrix. Taking maxima across that matrix identifies each GT box’s best anchors and each anchor’s best GT match; threshold rules then assign positive, negative, or ignored labels. Anchors partially outside the image are ignored before this comparison. section 11.4.2

IoU is not itself the box-regression target. Positive anchors receive coordinate offsets that transform an anchor’s center, width, and height toward its matched GT box. IoU instead decides which anchors participate in that localization learning. Later, overlapping proposal boxes can be reduced by NMS so that several high-scoring boxes around one object do not remain as duplicate detections. section 11.4.2

How Math and Architectures of Deep Learning covers it

How deep it goes
Defines overlap over union, explains its geometric interpretation, and gives threshold-based anchor-labeling and PyTorch computation procedures.
Examples
Uses overlapping bounding-box geometry, GT-to-anchor score matrices, and torchvision.ops.box_iou and nms calls.
What it assumes
Assumes bounding boxes, anchors, and ground-truth object annotations while defining IoU from overlap and union areas.
What you can do after
Apply it via torchvision.ops to assign anchor labels and suppress overlapping region proposals.
How it connects
Connects bounding boxes, anchor boxes, ground-truth boxes, region proposal networks, bounding-box regression, and non-maximal suppression.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math and Architectures of Deep Learning. The section links point to the parts of the book it draws on.