mindspore.dataset.vision.py_transforms.TenCrop

class mindspore.dataset.vision.py_transforms.TenCrop(size, use_vertical_flip=False)[source]

Crop the given image into one central crop and four corners plus the flipped version of these.

Parameters
  • size (Union[int, sequence]) – The output size of the cropped images. If size is an integer, a square of size (size, size) is returned. If size is a sequence of length 2, it should be in shape of (height, width).

  • use_vertical_flip (bool, optional) – Whether to flip the image vertically, otherwise horizontally (default=False).

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

  • TypeError – If use_vertical_flip is not of type boolean.

  • ValueError – If size is not positive.

Supported Platforms:

CPU

Examples

>>> import numpy
>>> from mindspore.dataset.transforms.py_transforms import Compose
>>> transforms_list = Compose([py_vision.Decode(),
...                            py_vision.TenCrop(size=200),
...                            # 4D stack of 10 images
...                            lambda *images: numpy.stack([py_vision.ToTensor()(image) for image in images])])
>>> # apply the transform to dataset through map function
>>> image_folder_dataset = image_folder_dataset.map(operations=transforms_list,
...                                                 input_columns="image")