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
scaleis 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
scaleis 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_ratiois True, the minimum value oftarget_scalewill be used to set the shorter side and the maximum value will be used to set the longer side.if
keep_ratiois False, the value oftarget_scalewill 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_typeis “Resize”, if it’s not overwritten by your registry, it indicates themmcv.Resize. And therefore,resize_kwargsaccepts any keyword arguments of it, likekeep_ratio,interpolationand so on.If you want to use your custom resize class, the class should accept
scaleargument and havescaleattribution which determines the resize shape.