Data Augmentation

tflearn.data_augmentation.DataAugmentation (self)

Base class for applying common real-time data augmentation.

This class is meant to be used as an argument of input_data. When training a model, the defined augmentation methods will be applied at training time only. Note that DataPreprocessing is similar to DataAugmentation, but applies at both training time and testing time.

Arguments

  • None

Image Augmentation

tflearn.data_augmentation.ImageAugmentation (self)

Base class for applying real-time augmentation related to images.

This class is meant to be used as an argument of input_data. When training a model, the defined augmentation methods will be applied at training time only. Note that ImagePreprocessing is similar to ImageAugmentation, but applies at both training time and testing time.

Arguments

  • None.

Methods

add_random_90degrees_rotation (rotations=[0, 1, 2, 3])

Randomly perform 90 degrees rotations.

Arguments
  • rotations: list. Allowed 90 degrees rotations.

add_random_blur (sigma_max=5.0)

Randomly blur an image by applying a gaussian filter with a random sigma (0., sigma_max).

Arguments
  • sigma: float or list of float. Standard deviation for Gaussian kernel. The standard deviations of the Gaussian filter are given for each axis as a sequence, or as a single number, in which case it is equal for all axes.
Returns

Nothing.

add_random_crop (crop_shape, padding=None)

Randomly crop a picture according to 'crop_shape'. An optional padding can be specified, for padding picture with 0s (To conserve original image shape).

Examples
# Example: pictures of 32x32
imgaug = tflearn.ImageAugmentation()
# Random crop of 24x24 into a 32x32 picture => output 24x24
imgaug.add_random_crop((24, 24))
# Random crop of 32x32 with image padding of 6 (to conserve original image shape) => output 32x32
imgaug.add_random_crop((32, 32), 6)
Arguments
  • crop_shape: tuple of int. The crop shape (height, width).
  • padding: int. If not None, the image is padded with 'padding' 0s.
Returns

Nothing.

add_random_flip_leftright (self)

Randomly flip an image (left to right).

Returns

Nothing.

add_random_flip_updown (self)

Randomly flip an image (upside down).

Returns

Nothing.

add_random_rotation (max_angle=20.0)

Randomly rotate an image by a random angle (-max_angle, max_angle).

Arguments
  • max_angle: float. The maximum rotation angle.
Returns

Nothing.