From a8a09f9fa53eb2e67a17657cda780eacfc12abbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikel=20Brostr=C3=B6m?= Date: Tue, 8 Oct 2024 23:20:00 +0200 Subject: [PATCH] delete duplicated giou --- boxmot/utils/iou.py | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/boxmot/utils/iou.py b/boxmot/utils/iou.py index 185d0672e..a4f9314a8 100644 --- a/boxmot/utils/iou.py +++ b/boxmot/utils/iou.py @@ -210,43 +210,6 @@ def diou_batch(bboxes1, bboxes2) -> np.ndarray: return (diou + 1) / 2.0 - - def giou_batch(self, bboxes1, bboxes2) -> np.ndarray: - """ - :param bbox_p: predict of bbox(N,4)(x1,y1,x2,y2) - :param bbox_g: groundtruth of bbox(N,4)(x1,y1,x2,y2) - :return: - """ - # for details should go to https://arxiv.org/pdf/1902.09630.pdf - # ensure predict's bbox form - bboxes2 = np.expand_dims(bboxes2, 0) - bboxes1 = np.expand_dims(bboxes1, 1) - - xx1 = np.maximum(bboxes1[..., 0], bboxes2[..., 0]) - yy1 = np.maximum(bboxes1[..., 1], bboxes2[..., 1]) - xx2 = np.minimum(bboxes1[..., 2], bboxes2[..., 2]) - yy2 = np.minimum(bboxes1[..., 3], bboxes2[..., 3]) - w = np.maximum(0.0, xx2 - xx1) - h = np.maximum(0.0, yy2 - yy1) - wh = w * h - iou = wh / ( - (bboxes1[..., 2] - bboxes1[..., 0]) * (bboxes1[..., 3] - bboxes1[..., 1]) + - (bboxes2[..., 2] - bboxes2[..., 0]) * (bboxes2[..., 3] - bboxes2[..., 1]) - - wh - ) - - xxc1 = np.minimum(bboxes1[..., 0], bboxes2[..., 0]) - yyc1 = np.minimum(bboxes1[..., 1], bboxes2[..., 1]) - xxc2 = np.maximum(bboxes1[..., 2], bboxes2[..., 2]) - yyc2 = np.maximum(bboxes1[..., 3], bboxes2[..., 3]) - wc = xxc2 - xxc1 - hc = yyc2 - yyc1 - assert (wc > 0).all() and (hc > 0).all() - area_enclose = wc * hc - giou = iou - (area_enclose - wh) / area_enclose - giou = (giou + 1.0) / 2.0 # resize from (-1,1) to (0,1) - return giou - @staticmethod def run_asso_func(self, bboxes1, bboxes2):