mindspore.dataset.vision

This module is to support vision augmentations. Some image augmentations are implemented with C++ OpenCV to provide high performance. Other additional image augmentations are developed with Python PIL.

Common imported modules in corresponding API examples are as follows:

import mindspore.dataset as ds
import mindspore.dataset.vision as vision
import mindspore.dataset.vision.utils as utils

Note: Legacy c_transforms and py_transforms are deprecated but can still be imported as follows:

import mindspore.dataset.vision.c_transforms as c_vision
import mindspore.dataset.vision.py_transforms as py_vision

See Image Data Processing and Augmentation tutorial for more details.

Descriptions of common data processing terms are as follows:

  • TensorOperation, the base class of all data processing operations implemented in C++.

  • ImageTensorOperation, the base class of all image processing operations. It is a derived class of TensorOperation.

  • PyTensorOperation, the base class of all data processing operations implemented in Python.

Transforms

mindspore.dataset.vision.AdjustGamma

Apply gamma correction on input image.

mindspore.dataset.vision.AutoAugment

Apply AutoAugment data augmentation method based on AutoAugment: Learning Augmentation Strategies from Data.

mindspore.dataset.vision.AutoContrast

Apply automatic contrast on input image.

mindspore.dataset.vision.BoundingBoxAugment

Apply a given image processing operation on a random selection of bounding box regions of a given image.

mindspore.dataset.vision.CenterCrop

Crop the input image at the center to the given size.

mindspore.dataset.vision.ConvertColor

Change the color space of the image.

mindspore.dataset.vision.Crop

Crop the input image at a specific location.

mindspore.dataset.vision.CutMixBatch

Apply CutMix transformation on input batch of images and labels.

mindspore.dataset.vision.CutOut

Randomly cut (mask) out a given number of square patches from the input image array.

mindspore.dataset.vision.Decode

Decode the input image in RGB mode.

mindspore.dataset.vision.Equalize

Apply histogram equalization on input image.

mindspore.dataset.vision.FiveCrop

Crop the given image into one central crop and four corners.

mindspore.dataset.vision.GaussianBlur

Blur input image with the specified Gaussian kernel.

mindspore.dataset.vision.Grayscale

Convert the input PIL Image to grayscale.

mindspore.dataset.vision.HorizontalFlip

Flip the input image horizontally.

mindspore.dataset.vision.HsvToRgb

Convert the input numpy.ndarray images from HSV to RGB.

mindspore.dataset.vision.HWC2CHW

Transpose the input image from shape (H, W, C) to (C, H, W).

mindspore.dataset.vision.Invert

Apply invert on input image in RGB mode.

mindspore.dataset.vision.LinearTransformation

Linearly transform the input numpy.ndarray image with a square transformation matrix and a mean vector.

mindspore.dataset.vision.MixUp

Randomly mix up a batch of images together with its labels.

mindspore.dataset.vision.MixUpBatch

Apply MixUp transformation on input batch of images and labels.

mindspore.dataset.vision.Normalize

Normalize the input image with respect to mean and standard deviation.

mindspore.dataset.vision.NormalizePad

Normalize the input image with respect to mean and standard deviation then pad an extra channel with value zero.

mindspore.dataset.vision.Pad

Pad the image according to padding parameters.

mindspore.dataset.vision.PadToSize

Pad the image to a fixed size.

mindspore.dataset.vision.RandomAdjustSharpness

Randomly adjust the sharpness of the input image with a given probability.

mindspore.dataset.vision.RandomAffine

Apply Random affine transformation to the input image.

mindspore.dataset.vision.RandomAutoContrast

Automatically adjust the contrast of the image with a given probability.

mindspore.dataset.vision.RandomColor

Adjust the color of the input image by a fixed or random degree.

mindspore.dataset.vision.RandomColorAdjust

Randomly adjust the brightness, contrast, saturation, and hue of the input image.

mindspore.dataset.vision.RandomCrop

Crop the input image at a random location.

mindspore.dataset.vision.RandomCropDecodeResize

A combination of Crop, Decode and Resize.

mindspore.dataset.vision.RandomCropWithBBox

Crop the input image at a random location and adjust bounding boxes accordingly.

mindspore.dataset.vision.RandomEqualize

Apply histogram equalization on the input image with a given probability.

mindspore.dataset.vision.RandomErasing

Randomly erase pixels within a random selected rectangle erea on the input numpy.ndarray image.

mindspore.dataset.vision.RandomGrayscale

Randomly convert the input PIL Image to grayscale.

mindspore.dataset.vision.RandomHorizontalFlip

Randomly flip the input image horizontally with a given probability.

mindspore.dataset.vision.RandomHorizontalFlipWithBBox

Flip the input image horizontally randomly with a given probability and adjust bounding boxes accordingly.

mindspore.dataset.vision.RandomInvert

Randomly invert the colors of image with a given probability.

mindspore.dataset.vision.RandomLighting

Add AlexNet-style PCA-based noise to an image.

mindspore.dataset.vision.RandomPerspective

Randomly apply perspective transformation to the input PIL Image with a given probability.

mindspore.dataset.vision.RandomPosterize

Reduce the number of bits for each color channel to posterize the input image randomly with a given probability.

mindspore.dataset.vision.RandomResizedCrop

This operator will crop the input image randomly, and resize the cropped image using a selected interpolation mode.

mindspore.dataset.vision.RandomResizedCropWithBBox

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

mindspore.dataset.vision.RandomResize

Resize the input image using a randomly selected interpolation mode.

mindspore.dataset.vision.RandomResizeWithBBox

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

mindspore.dataset.vision.RandomRotation

Rotate the input image randomly within a specified range of degrees.

mindspore.dataset.vision.RandomSelectSubpolicy

Choose a random sub-policy from a policy list to be applied on the input image.

mindspore.dataset.vision.RandomSharpness

Adjust the sharpness of the input image by a fixed or random degree.

mindspore.dataset.vision.RandomSolarize

Randomly selects a subrange within the specified threshold range and sets the pixel value within the subrange to (255 - pixel).

mindspore.dataset.vision.RandomVerticalFlip

Randomly flip the input image vertically with a given probability.

mindspore.dataset.vision.RandomVerticalFlipWithBBox

Flip the input image vertically, randomly with a given probability and adjust bounding boxes accordingly.

mindspore.dataset.vision.Rescale

Rescale the input image with the given rescale and shift.

mindspore.dataset.vision.Resize

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

mindspore.dataset.vision.ResizeWithBBox

Resize the input image to the given size and adjust bounding boxes accordingly.

mindspore.dataset.vision.RgbToHsv

Convert the input numpy.ndarray images from RGB to HSV.

mindspore.dataset.vision.Rotate

Rotate the input image by specified degrees.

mindspore.dataset.vision.SlicePatches

Slice Tensor to multiple patches in horizontal and vertical directions.

mindspore.dataset.vision.TenCrop

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

mindspore.dataset.vision.ToNumpy

Convert the PIL input image to numpy.ndarray image.

mindspore.dataset.vision.ToPIL

Convert the input decoded numpy.ndarray image to PIL Image.

mindspore.dataset.vision.ToTensor

Convert the input PIL Image or numpy.ndarray to numpy.ndarray of the desired dtype, rescale the pixel value range from [0, 255] to [0.0, 1.0] and change the shape from (H, W, C) to (C, H, W).

mindspore.dataset.vision.ToType

Cast the input to a given MindSpore data type or NumPy data type.

mindspore.dataset.vision.UniformAugment

Uniformly select a number of transformations from a sequence and apply them sequentially and randomly, which means that there is a chance that a chosen transformation will not be applied.

mindspore.dataset.vision.VerticalFlip

Flip the input image vertically.

Utilities

mindspore.dataset.vision.AutoAugmentPolicy

AutoAugment policy for different datasets.

mindspore.dataset.vision.Border

Padding Mode, Border Type.

mindspore.dataset.vision.ConvertMode

The color conversion mode.

mindspore.dataset.vision.ImageBatchFormat

Data Format of images after batch operation.

mindspore.dataset.vision.Inter

Interpolation Modes.

mindspore.dataset.vision.SliceMode

Mode to Slice Tensor into multiple parts.

mindspore.dataset.vision.get_image_num_channels

Get the number of input image channels.

mindspore.dataset.vision.get_image_size

Get the size of input image as [height, width].