mindspore.dataset.vision.Resize

View Source On Gitee
class mindspore.dataset.vision.Resize(size, interpolation=Inter.LINEAR)[source]

Resize the input image to the given size with a given interpolation mode Inter .

Parameters
  • size (Union[int, Sequence[int]]) – The output size of the resized image. The size value(s) must be positive. If size is an integer, the 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).

  • interpolation (Inter, optional) – Image interpolation method defined by Inter . Default: Inter.LINEAR.

Raises
Supported Platforms:

CPU Ascend

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>> from mindspore.dataset.vision import Inter
>>>
>>> decode_op = vision.Decode()
>>> resize_op = vision.Resize([100, 75], Inter.BICUBIC)
>>> transforms_list = [decode_op, resize_op]
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"])
Tutorial Examples:
device(device_target='CPU')[source]

Set the device for the current operator execution.

Parameters

device_target (str, optional) – The operator will be executed on this device. Currently supports CPU . Default: CPU .

Raises
  • TypeError – If device_target is not of type str.

  • ValueError – If device_target is not CPU .

Supported Platforms:

CPU

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>> from mindspore.dataset.vision import Inter
>>>
>>> decode_op = vision.Decode()
>>> resize_op = vision.Resize([100, 75], Inter.BICUBIC).device("Ascend")
>>> transforms_list = [decode_op, resize_op]
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"])
Tutorial Examples: