From 86c7579b421b5e7cbde34162b427488ebd6d0974 Mon Sep 17 00:00:00 2001 From: Yunhao Meng Date: Fri, 3 Oct 2025 20:23:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=9D=9E=E6=9E=81=E5=A4=A7?= =?UTF-8?q?=E5=80=BC=E6=8A=91=E5=88=B6=E5=87=BD=E6=95=B0=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=BC=A0=E9=87=8F=E7=BB=B4=E5=BA=A6=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E6=9B=B4=E6=96=B0compute=5Fap=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E4=BB=A5=E4=BD=BF=E7=94=A8numpy.trapezoid=E6=9B=BF=E4=BB=A3?= =?UTF-8?q?=E5=B7=B2=E5=BC=83=E7=94=A8=E7=9A=84numpy.trapz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/util.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/util.py b/utils/util.py index 08ea61b..59886c9 100644 --- a/utils/util.py +++ b/utils/util.py @@ -151,7 +151,7 @@ def non_max_suppression(outputs, confidence_threshold=0.001, iou_threshold=0.65) box = wh2xy(box) # (cx, cy, w, h) to (x1, y1, x2, y2) if nc > 1: i, j = (cls > confidence_threshold).nonzero(as_tuple=False).T - x = torch.cat((box[i], x[i, 4 + j, None], j[:, None].float()), dim=1) + x = torch.cat((box[i], x[i, 4 + j].unsqueeze(1), j[:, None].float()), dim=1) else: # best class only conf, j = cls.max(1, keepdim=True) x = torch.cat((box, conf, j.float()), 1)[conf.view(-1) > confidence_threshold] @@ -296,7 +296,8 @@ def compute_ap(tp, conf, output, target, plot=False, names=(), eps=1e-16): # Integrate area under curve x = numpy.linspace(start=0, stop=1, num=101) # 101-point interp (COCO) - ap[ci, j] = numpy.trapz(numpy.interp(x, m_rec, m_pre), x) # integrate + # numpy.trapz is deprecated in numpy 2.0.0 or after version, use numpy.trapezoid instead + ap[ci, j] = numpy.trapezoid(numpy.interp(x, m_rec, m_pre), x) # integrate if plot and j == 0: py.append(numpy.interp(px, m_rec, m_pre)) # precision at mAP@0.5