Skip to content

Commit

Permalink
move comments to docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
GT9505 committed Dec 10, 2021
1 parent 32d934d commit f04645a
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions mmdet/datasets/pipelines/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f04645a

Please sign in to comment.