Chapter 2: Deep learning

Detection metrics: IoU, NMS and mAP

A detector does not give one right-or-wrong answer: it draws many boxes, and each box has a score. You will be able to measure how well two boxes overlap, delete duplicate boxes, and turn a ranked list of boxes into one score. Interviewers often ask you to code the first two and to explain the score.

20 minInteractive lessonChapter 2: Deep learningLesson 11 of 20

What you will learn

  • Compute IoU between two boxes
  • Implement greedy non-maximum suppression
  • Compute average precision for one class from ranked detections

Key terms

bounding box
a rectangle around an object, written [x1, y1, x2, y2]
ground truth
the true box that a person drew around a real object
IoU
a score from 0 to 1 for how much two boxes overlap
NMS
a step that deletes duplicate boxes for the same object
mAP
one score for a whole detector, found from ranked boxes

Prerequisites

Take Convolutions, residual blocks and conv arithmetic first. It comes right before this lesson in the course.

Where this lesson picks up: You saw how conv layers turn a photo into feature maps, and you worked out their output shapes. A detector reads those maps and draws boxes with scores, so how do we decide if the boxes are good?

What comes next

Next, you will ask whether the feature maps should come from convolutions or from a newer design, the vision transformer.

Next lesson: CNNs vs ViTs and transfer learning

More lessons in this part

Take the lesson

Short cards, one idea at a time, with quick checks as you go.