Skip to content

Commit

Permalink
[Fix] Fix ppyoloerandomcrop (#817)
Browse files Browse the repository at this point in the history
* fix ppyoloerandomcrop

* fix maskrefine

---------

Co-authored-by: Lingrui Gu <[email protected]>
  • Loading branch information
Nioolek and Lingrui Gu authored Jul 19, 2023
1 parent 106bec4 commit 85958c8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mmyolo/datasets/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 85958c8

Please sign in to comment.