mindspore.dataset.vision.c_transforms.RandomResize

class mindspore.dataset.vision.c_transforms.RandomResize(size)[source]

Resize the input image using a randomly selected interpolation mode.

Parameters

size (Union[int, sequence]) – The output size of the resized image. The size value(s) must be positive. If size is an integer, smaller edge of the image will be resized to this value with the same image aspect ratio. If size is a sequence of length 2, it should be (height, width).

Raises
  • TypeError – If size is not of type integer or sequence of integer.

  • ValueError – If size is not positive.

  • RuntimeError – If given tensor shape is not <H, W> or <H, W, C>.

Supported Platforms:

CPU

Examples

>>> # randomly resize image, keeping aspect ratio
>>> transforms_list1 = [c_vision.Decode(), c_vision.RandomResize(50)]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list1,
...                                                 input_columns=["image"])
>>> # randomly resize image to landscape style
>>> transforms_list2 = [c_vision.Decode(), c_vision.RandomResize((40, 60))]
>>> image_folder_dataset_1 = image_folder_dataset_1.map(operations=transforms_list2,
...                                                     input_columns=["image"])