See the Glossary for the meaning of the acronyms used in this guide.

A task plugin module for preparing Tensorflow-specific dataset iterators.

create_image_dataset(data_dir: str, subset: Optional[str], image_size: Tuple[int, int, int], seed: int, rescale: float = 0.00392156862745098, validation_split: Optional[float] = 0.2, batch_size: int = 32, label_mode: str = 'categorical') tf.keras.preprocessing.image.DirectoryIterator[source]#

Yields an iterator for generating batches of real-time augmented image data.

  • data_dir – The directory containing the image dataset.

  • subset – The subset of data (“training” or “validation”) to use if validation_split is not None. If None, then validation_split must also be None.

  • image_size – A tuple of integers (height, width, channels) used to preprocess the images so that they all have the same dimensions and number of color channels. channels=3 means RGB color images and channels=1 means grayscale images. Images with different dimensions will be resized. If channels=1, color images will be converted into grayscale.

  • seed – Sets the random seed used for shuffling and transformations.

  • rescale – The rescaling factor for the pixel vectors. If None or 0, no rescaling is applied, otherwise multiply the data by the value provided (after applying all other transformations). The default is 1.0 / 255.

  • validation_split – The fraction of the data to set aside for validation. If not None, the value given here must be between 0 and 1. If None, then there is no validation set. The default is 0.2.

  • batch_size – The size of the batch on which adversarial samples are generated. The default is 32.

  • label_mode – Determines how the label arrays for the dataset will be returned. The available choices are: “categorical”, “binary”, “sparse”, “input”, None. For information on the meaning of each choice, see the documentation for tensorflow.keras.preprocessing.image.ImageDataGenerator.flow_from_directory(). The default is “categorical”.


A tf.keras.preprocessing.image.DirectoryIterator object.

See also

get_n_classes_from_directory_iterator(ds: tf.keras.preprocessing.image.DirectoryIterator) int[source]#

Returns the number of unique labels found by the tf.keras.preprocessing.image.DirectoryIterator.


ds – A tf.keras.preprocessing.image.DirectoryIterator object.


The number of unique labels in the dataset.