mindspore.dataset.vision.RandomResizeWithBBox

class mindspore.dataset.vision.RandomResizeWithBBox(size)[source]

Tensor operation to resize the input image using a randomly selected interpolation mode mindspore.dataset.vision.Inter and adjust bounding boxes accordingly.

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, 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 int or Sequence[int].

  • ValueError – If size is not positive.

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

Supported Platforms:

CPU

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>>
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>>
>>> # 1) randomly resize image with bounding boxes, keeping aspect ratio
>>> transforms_list1 = [vision.Decode(), vision.RandomResizeWithBBox(60)]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list1,
...                                                 input_columns=["image"])
>>>
>>> # 2) randomly resize image with bounding boxes to portrait style
>>> transforms_list2 = [vision.Decode(), vision.RandomResizeWithBBox((80, 60))]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list2,
...                                                 input_columns=["image"])
Tutorial Examples: