mindspore.dataset.vision.py_transforms.RandomResizedCrop
- class mindspore.dataset.vision.py_transforms.RandomResizedCrop(size, scale=(0.08, 1.0), ratio=(3.0 / 4.0, 4.0 / 3.0), interpolation=Inter.BILINEAR, max_attempts=10)[source]
Extract crop from the input image and resize it to a random size and aspect ratio.
- Parameters
size (Union[int, sequence]) – The size of the output image. If size is an integer, a square crop of size (size, size) is returned. If size is a sequence of length 2, it should be (height, width).
scale (list, tuple, optional) – Range (min, max) of respective size of the original size to be cropped (default=(0.08, 1.0)).
ratio (list, tuple, optional) – Range (min, max) of aspect ratio to be cropped (default=(3. / 4., 4. / 3.)).
interpolation (Inter mode, optional) –
Image interpolation mode (default=Inter.BILINEAR). It can be any of [Inter.NEAREST, Inter.ANTIALIAS, Inter.BILINEAR, Inter.BICUBIC].
Inter.NEAREST, means the interpolation method is nearest-neighbor interpolation.
Inter.ANTIALIAS, means the interpolation method is antialias interpolation.
Inter.BILINEAR, means the interpolation method is bilinear interpolation.
Inter.BICUBIC, means the interpolation method is bicubic interpolation.
max_attempts (int, optional) – The maximum number of attempts to propose a valid crop area (default=10). If exceeded, fall back to use center crop instead.
Examples
>>> from mindspore.dataset.transforms.py_transforms import Compose >>> transforms_list = Compose([py_vision.Decode(), ... py_vision.RandomResizedCrop(224), ... py_vision.ToTensor()]) >>> # apply the transform to dataset through map function >>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list, ... input_columns="image")