mindspore.dataset.vision.c_transforms.RandomResizedCropWithBBox

class mindspore.dataset.vision.c_transforms.RandomResizedCropWithBBox(size, scale=(0.08, 1.0), ratio=(3.0 / 4.0, 4.0 / 3.0), interpolation=Inter.BILINEAR, max_attempts=10)[source]

Crop the input image to a random size and aspect ratio and adjust bounding boxes accordingly.

Parameters
  • size (Union[int, Sequence[int]]) – The size of the output image. The size value(s) must be positive. If size is an integer, a square of size (size, size) will be cropped with this value. If size is a sequence of length 2, an image of size (height, width) will be cropped.

  • scale (Union[list, tuple], optional) – Range (min, max) of respective size of the original size to be cropped, which must be non-negative (default=(0.08, 1.0)).

  • ratio (Union[list, tuple], optional) – Range (min, max) of aspect ratio to be cropped, which must be non-negative (default=(3. / 4., 4. / 3.)).

  • interpolation (Inter mode, optional) –

    Method of interpolation (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.

Raises
Supported Platforms:

CPU

Examples

>>> from mindspore.dataset.vision import Inter
>>> decode_op = c_vision.Decode()
>>> bbox_op = c_vision.RandomResizedCropWithBBox(size=50, interpolation=Inter.NEAREST)
>>> transforms_list = [decode_op, bbox_op]
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns=["image"])