RandomResizedCrop¶
- class mmpretrain.datasets.transforms.RandomResizedCrop(scale, crop_ratio_range=(0.08, 1.0), aspect_ratio_range=(0.75, 1.3333333333333333), max_attempts=10, interpolation='bilinear', backend='cv2')[source]¶
Crop the given image to random scale and aspect ratio.
A crop of random size (default: of 0.08 to 1.0) of the original size and a random aspect ratio (default: of 3/4 to 4/3) of the original aspect ratio is made. This crop is finally resized to given size.
Required Keys:
img
Modified Keys:
img
img_shape
- Parameters:
scale (sequence | int) – Desired output scale of the crop. If size is an int instead of sequence like (h, w), a square crop (size, size) is made.
crop_ratio_range (tuple) – Range of the random size of the cropped image compared to the original image. Defaults to (0.08, 1.0).
aspect_ratio_range (tuple) – Range of the random aspect ratio of the cropped image compared to the original image. Defaults to (3. / 4., 4. / 3.).
max_attempts (int) – Maximum number of attempts before falling back to Central Crop. Defaults to 10.
interpolation (str) – Interpolation method, accepted values are ‘nearest’, ‘bilinear’, ‘bicubic’, ‘area’, ‘lanczos’. Defaults to ‘bilinear’.
backend (str) – The image resize backend type, accepted values are ‘cv2’ and ‘pillow’. Defaults to ‘cv2’.