From 85958c82e2111aee55bd63136906cd2cdc6c0ed6 Mon Sep 17 00:00:00 2001 From: Nioolek <40284075+Nioolek@users.noreply.github.com> Date: Wed, 19 Jul 2023 11:34:45 +0800 Subject: [PATCH] [Fix] Fix ppyoloerandomcrop (#817) * fix ppyoloerandomcrop * fix maskrefine --------- Co-authored-by: Lingrui Gu --- mmyolo/datasets/transforms/transforms.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mmyolo/datasets/transforms/transforms.py b/mmyolo/datasets/transforms/transforms.py index 12d15c960..8060e9c72 100644 --- a/mmyolo/datasets/transforms/transforms.py +++ b/mmyolo/datasets/transforms/transforms.py @@ -793,6 +793,7 @@ def transform(self, results: dict) -> dict: num_bboxes = len(bboxes) if num_bboxes: orig_bboxes = bboxes.clone() + orig_bboxes.rescale_([scaling_ratio, scaling_ratio]) if 'gt_masks' in results: # If the dataset has annotations of mask, # the mask will be used to refine bbox. @@ -817,8 +818,6 @@ def transform(self, results: dict) -> dict: bboxes.clip_([height, width]) # filter bboxes - orig_bboxes.rescale_([scaling_ratio, scaling_ratio]) - # Be careful: valid_index must convert to numpy, # otherwise it will raise out of bounds when len(valid_index)=1 valid_index = self.filter_gt_bboxes(orig_bboxes, @@ -1499,8 +1498,8 @@ def _iou_matrix(self, overlap = np.prod( rightbottom - lefttop, axis=2) * (lefttop < rightbottom).all(axis=2) - area_gt_bbox = np.prod(gt_bbox[:, 2:] - crop_bbox[:, :2], axis=1) - area_crop_bbox = np.prod(gt_bbox[:, 2:] - crop_bbox[:, :2], axis=1) + area_gt_bbox = np.prod(gt_bbox[:, 2:] - gt_bbox[:, :2], axis=1) + area_crop_bbox = np.prod(crop_bbox[:, 2:] - crop_bbox[:, :2], axis=1) area_o = (area_gt_bbox[:, np.newaxis] + area_crop_bbox - overlap) return overlap / (area_o + eps)