Trusted answers to developer questions

Rana Abdul Muneem

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

**Object detection** is a method of recognizing and locating instances of an object from an image or video. **Mean average precision (mAP)** is a metric used to measure the accuracy of object detection models.

It is a value between

The following formula describes it:

In the formula above, **average precision** of class *average* of average precisions across all classes.

To understand the calculation of mAP for object detection, we must first explore intersection over union, precision-recall curve, and average precision.

**Intersection over union (IOU)** is a metric used to measure the accuracy of a **actual bounding box** is the desired box that we set ourselves. The following image gives examples of actual and predicted bounding boxes.

IOU is the extent to which the predicted bounding box overlaps with the actual bounding box. It is a value between

An IOU is calculated by:

A visual representation of the IOU formula

IOU scores are converted into positive or negative predictions using a threshold. A typical threshold is

The following table highlights how samples are categorized.

Evaluating Metrics

True positve (TP) | False positive (FP) | False negative (FN) |

The predicted class is correct, and IOU is greater than or equal to the threshold. | The IOU score is less than the threshold (less than 0.5) or multiple bounding boxes have been predicted. | The IOU score was greater than or equal to 0.5 but the prediction was made for the wrong class. |

The training data is assumed to have some objects present in each image. As a result, true negatives (TN) are not considered.

A **precision-recall curve** is a graph that shows the tradeoff between precision and recall.

A precision-recall curve can be plotted by following these steps:

- Passing dataset of images to the object detection model.
- Sorting results based on the received
.confidence scores A value between 0â€“1 indicating the models certainty in its prediction. - Determining if the prediction was TP, FP, or FN.
- Calculating
andranked precision Precision for top k sorted results .ranked recall Recall for top k sorted results

To understand the calculations in each step, let's consider an object detection model that can classify dogs. Let's suppose that the dataset contains only four images of dogs.

For each image, the model returns a bounding box, a predicted class, and a

The confidence score is returned for each image

The resultant values generate the following curve:

**Average precision** is the area under the generated precision-recall curve. However, it is common practice to first smooth out the zig-zag pattern.

Using

Identifying unique recall values

This results in the following graph:

There are many different variations for calculating AP from the precision-recall curve. The Pascal VOC challenge uses an 11-point interpolation.

- The recalls are divided into 11 points (0 to 1.0 with a step size of 0.1).
- We note the precision values at these 11 recall points.
- AP is the average of these noted precision values.

In the equation above,

For the ongoing example, AP is calculated below:

The calculation for AP is repeated for each class of the object detector. The mAP for the model is the average of calculated APs.

Calculation of mAP across three classes

RELATED TAGS

precision

average precision

object detection

CONTRIBUTOR

Rana Abdul Muneem

Copyright Â©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Related Courses