From f04645aba3762536d66e833db60f0842f28798b8 Mon Sep 17 00:00:00 2001 From: Tao Gong Date: Fri, 10 Dec 2021 14:10:21 +0800 Subject: [PATCH] move comments to docstring --- mmdet/datasets/pipelines/transforms.py | 31 ++++++++++---------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/mmdet/datasets/pipelines/transforms.py b/mmdet/datasets/pipelines/transforms.py index 6e349c10c13..d11586d0e60 100644 --- a/mmdet/datasets/pipelines/transforms.py +++ b/mmdet/datasets/pipelines/transforms.py @@ -55,7 +55,9 @@ class Resize: keep_ratio (bool): Whether to keep the aspect ratio when resizing the image. bbox_clip_border (bool, optional): Whether to clip the objects outside - the border of the image. Defaults to True. + the border of the image. In some dataset like MOT17, the gt bboxes + are allowed to cross the border of images. Therefore, we don't + need to clip the gt bboxes in these cases. Defaults to True. backend (str): Image resize backend, choices are 'cv2' and 'pillow'. These two backends generates slightly different results. Defaults to 'cv2'. @@ -239,9 +241,6 @@ def _resize_bboxes(self, results): """Resize bounding boxes with ``results['scale_factor']``.""" for key in results.get('bbox_fields', []): bboxes = results[key] * results['scale_factor'] - # In some dataset like MOT17, the gt bboxes are allowed to cross - # the border of images. Therefore, we don't need to clip the gt - # bboxes in these cases. if self.bbox_clip_border: img_shape = results['img_shape'] bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1]) @@ -1986,7 +1985,9 @@ class Mosaic: min_bbox_size (int | float): The minimum pixel for filtering invalid bboxes after the mosaic pipeline. Default to 0. bbox_clip_border (bool, optional): Whether to clip the objects outside - the border of the image. Defaults to True. + the border of the image. In some dataset like MOT17, the gt bboxes + are allowed to cross the border of images. Therefore, we don't + need to clip the gt bboxes in these cases. Defaults to True. skip_filter (bool): Whether to skip filtering rules. If it is True, the filter rule will not be applied, and the `min_bbox_size` is invalid. Default to True. @@ -2108,9 +2109,6 @@ def _mosaic_transform(self, results): mosaic_bboxes = np.concatenate(mosaic_bboxes, 0) mosaic_labels = np.concatenate(mosaic_labels, 0) - # In some dataset like MOT17, the gt bboxes are allowed to cross - # the border of images. Therefore, we don't need to clip the gt - # bboxes in these cases. if self.bbox_clip_border: mosaic_bboxes[:, 0::2] = np.clip(mosaic_bboxes[:, 0::2], 0, 2 * self.img_scale[1]) @@ -2261,7 +2259,9 @@ class MixUp: threshold to filter bboxes. If max(h/w, w/h) larger than this value, the box will be removed. Default: 20. bbox_clip_border (bool, optional): Whether to clip the objects outside - the border of the image. Defaults to True. + the border of the image. In some dataset like MOT17, the gt bboxes + are allowed to cross the border of images. Therefore, we don't + need to clip the gt bboxes in these cases. Defaults to True. skip_filter (bool): Whether to skip filtering rules. If it is True, the filter rule will not be applied, and the `min_bbox_size` and `min_area_ratio` and `max_aspect_ratio` @@ -2394,9 +2394,6 @@ def _mixup_transform(self, results): retrieve_gt_bboxes = retrieve_results['gt_bboxes'] retrieve_gt_bboxes[:, 0::2] = retrieve_gt_bboxes[:, 0::2] * scale_ratio retrieve_gt_bboxes[:, 1::2] = retrieve_gt_bboxes[:, 1::2] * scale_ratio - # In some dataset like MOT17, the gt bboxes are allowed to cross - # the border of images. Therefore, we don't need to clip the gt - # bboxes in these cases. if self.bbox_clip_border: retrieve_gt_bboxes[:, 0::2] = np.clip(retrieve_gt_bboxes[:, 0::2], 0, origin_w) @@ -2413,9 +2410,6 @@ def _mixup_transform(self, results): cp_retrieve_gt_bboxes[:, 0::2] - x_offset cp_retrieve_gt_bboxes[:, 1::2] = \ cp_retrieve_gt_bboxes[:, 1::2] - y_offset - # In some dataset like MOT17, the gt bboxes are allowed to cross - # the border of images. Therefore, we don't need to clip the gt - # bboxes in these cases. if self.bbox_clip_border: cp_retrieve_gt_bboxes[:, 0::2] = np.clip( cp_retrieve_gt_bboxes[:, 0::2], 0, target_w) @@ -2512,7 +2506,9 @@ class RandomAffine: threshold to filter bboxes. If max(h/w, w/h) larger than this value, the box will be removed. bbox_clip_border (bool, optional): Whether to clip the objects outside - the border of the image. Defaults to True. + the border of the image. In some dataset like MOT17, the gt bboxes + are allowed to cross the border of images. Therefore, we don't + need to clip the gt bboxes in these cases. Defaults to True. skip_filter (bool): Whether to skip filtering rules. If it is True, the filter rule will not be applied, and the `min_bbox_size` and `min_area_ratio` and `max_aspect_ratio` @@ -2604,9 +2600,6 @@ def __call__(self, results): warp_bboxes = np.vstack( (xs.min(1), ys.min(1), xs.max(1), ys.max(1))).T - # In some dataset like MOT17, the gt bboxes are allowed to - # cross the border of images. Therefore, we don't need to clip - # the gt bboxes in these cases. if self.bbox_clip_border: warp_bboxes[:, [0, 2]] = \ warp_bboxes[:, [0, 2]].clip(0, width)