From f9d714f6e2f9931aa1c5f12b3cf2f79293d3a4f6 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 27 Aug 2021 13:23:29 +0200 Subject: [PATCH] Fix for AP calculation limits 0.0 - 1.0 (#4563) This PR brings alignment in AP computation practices with Detectron2 and MMDetection. Problem first noted by @yusiyoh in https://github.com/ultralytics/yolov5/issues/4546 --- utils/metrics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/metrics.py b/utils/metrics.py index ddc425910a75..44b9a3c16488 100644 --- a/utils/metrics.py +++ b/utils/metrics.py @@ -91,8 +91,8 @@ def compute_ap(recall, precision): """ # Append sentinel values to beginning and end - mrec = np.concatenate(([0.], recall, [recall[-1] + 0.01])) - mpre = np.concatenate(([1.], precision, [0.])) + mrec = np.concatenate(([0.0], recall, [1.0])) + mpre = np.concatenate(([1.0], precision, [0.0])) # Compute the precision envelope mpre = np.flip(np.maximum.accumulate(np.flip(mpre)))