RandomResize¶
- class mmpretrain.datasets.transforms.RandomResize(scale, ratio_range=None, resize_type='Resize', **resize_kwargs)[source]¶
Random resize images & bbox & keypoints.
How to choose the target scale to resize the image will follow the rules below:
if
scale
is a sequence of tuple
\[target\_scale[0] \sim Uniform([scale[0][0], scale[1][0]])\]\[target\_scale[1] \sim Uniform([scale[0][1], scale[1][1]])\]Following the resize order of weight and height in cv2,
scale[i][0]
is for width, andscale[i][1]
is for height.if
scale
is a tuple
\[target\_scale[0] \sim Uniform([ratio\_range[0], ratio\_range[1]]) * scale[0]\]\[target\_scale[1] \sim Uniform([ratio\_range[0], ratio\_range[1]]) * scale[1]\]Following the resize order of weight and height in cv2,
ratio_range[0]
is for width, andratio_range[1]
is for height.if
keep_ratio
is True, the minimum value oftarget_scale
will be used to set the shorter side and the maximum value will be used to set the longer side.if
keep_ratio
is False, the value oftarget_scale
will be used to reisze the width and height accordingly.
Required Keys:
img
gt_bboxes
gt_seg_map
gt_keypoints
Modified Keys:
img
gt_bboxes
gt_seg_map
gt_keypoints
img_shape
Added Keys:
scale
scale_factor
keep_ratio
- Parameters:
Note
By defaults, the
resize_type
is “Resize”, if it’s not overwritten by your registry, it indicates themmcv.Resize
. And therefore,resize_kwargs
accepts any keyword arguments of it, likekeep_ratio
,interpolation
and so on.If you want to use your custom resize class, the class should accept
scale
argument and havescale
attribution which determines the resize shape.