mirror of https://github.com/open-mmlab/mmyolo.git
[Fix] Fix ppyoloerandomcrop (#817)
* fix ppyoloerandomcrop * fix maskrefine --------- Co-authored-by: Lingrui Gu <lingrui.gu@nanovision.com.cn>pull/851/head
parent
106bec4edc
commit
85958c82e2
|
@ -793,6 +793,7 @@ class YOLOv5RandomAffine(BaseTransform):
|
|||
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 @@ class YOLOv5RandomAffine(BaseTransform):
|
|||
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 @@ class PPYOLOERandomCrop(BaseTransform):
|
|||
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue