tf.keras.preprocessing.image.ImageDataGenerator

DEPRECATED.

Used in the notebooks

Used in the guide

Methods

apply_transform

View source

Applies a transformation to an image according to given parameters.

Args
x 3D tensor, single image.
transform_parameters Dictionary with string - parameter pairs describing the transformation. Currently, the following parameters from the dictionary are used:

  • 'theta': Float. Rotation angle in degrees.
  • 'tx': Float. Shift in the x direction.
  • 'ty': Float. Shift in the y direction.
  • 'shear': Float. Shear angle in degrees.
  • 'zx': Float. Zoom in the x direction.
  • 'zy': Float. Zoom in the y direction.
  • 'flip_horizontal': Boolean. Horizontal flip.
  • 'flip_vertical': Boolean. Vertical flip.
  • 'channel_shift_intensity': Float. Channel shift intensity.
  • 'brightness': Float. Brightness shift intensity.

Returns
A transformed version of the input (same shape).

fit

View source

Fits the data generator to some sample data.

This computes the internal data stats related to the data-dependent transformations, based on an array of sample data.

Only required if featurewise_center or featurewise_std_normalization or zca_whitening are set to True.

When rescale is set to a value, rescaling is applied to sample data before computing the internal data stats.

Args
x Sample data. Should have rank 4. In case of grayscale data, the channels axis should have value 1, in case of RGB data, it should have value 3, and in case of RGBA data, it should have value 4.
augment Boolean (default: False). Whether to fit on randomly augmented samples.
rounds Int (default: 1). If using data augmentation (augment=True), this is how many augmentation passes over the data to use.
seed Int (default: None). Random seed.

flow

View source

flow_from_dataframe

View source

flow_from_directory

View source

get_random_transform

View source

Generates random parameters for a transformation.

Args
img_shape Tuple of integers. Shape of the image that is transformed.
seed Random seed.

Returns
A dictionary containing randomly chosen parameters describing the transformation.

random_transform

View source

Applies a random transformation to an image.

Args
x 3D tensor, single image.
seed Random seed.

Returns
A randomly transformed version of the input (same shape).

standardize

View source

Applies the normalization configuration in-place to a batch of inputs.

x is changed in-place since the function is mainly used internally to standardize images and feed them to your network. If a copy of x would be created instead it would have a significant performance cost. If you want to apply this method without changing the input in-place you can call the method creating a copy before:

standardize(np.copy(x))

Args
x Batch of inputs to be normalized.

Returns
The inputs, normalized.