mindspore.dataset.vision.c_transforms.RandomCropDecodeResize

class mindspore.dataset.vision.c_transforms.RandomCropDecodeResize(size, scale=(0.08, 1.0), ratio=(0.75, 1.3333333333333333), interpolation=Inter.BILINEAR, max_attempts=10)[source]

Equivalent to RandomResizedCrop, but crops before decodes.

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 (tuple, optional) – Range [min, max) of respective size of the original size to be cropped (default=(0.08, 1.0)).

  • ratio (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.BILINEAR, Inter.NEAREST, Inter.BICUBIC].

    • Inter.BILINEAR, means interpolation method is bilinear interpolation.

    • Inter.NEAREST, means interpolation method is nearest-neighbor interpolation.

    • Inter.BICUBIC, means 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

>>> import mindspore.dataset.vision.c_transforms as c_vision
>>> from mindspore.dataset.transforms.vision import Inter
>>>
>>> resize_crop_decode_op = c_vision.RandomCropDecodeResize(size=(50, 75), scale=(0.25, 0.5),
>>>     interpolation=Inter.NEAREST, max_attempts=5)
>>> transforms_list = [resize_crop_decode_op]
>>> data1 = data1.map(operations=transforms_list, input_columns=["image"])