@@ -1225,9 +1225,9 @@ class ImageDataGenerator:
12251225 `fill_mode = "constant"`.
12261226 horizontal_flip: Boolean. Randomly flip inputs horizontally.
12271227 vertical_flip: Boolean. Randomly flip inputs vertically.
1228- rescale: rescaling factor. Defaults to None. If None or 0, no rescaling
1228+ rescale: rescaling factor. If None or 0, no rescaling
12291229 is applied, otherwise we multiply the data by the value provided
1230- (after applying all other transformations).
1230+ (after applying all other transformations). Defaults to `None`.
12311231 preprocessing_function: function that will be applied on each input. The
12321232 function will run after the image is resized and augmented.
12331233 The function should take one argument: one image (Numpy tensor with
@@ -1236,9 +1236,9 @@ class ImageDataGenerator:
12361236 "channels_last". "channels_last" mode means that the images should
12371237 have shape `(samples, height, width, channels)`, "channels_first" mode
12381238 means that the images should have shape `(samples, channels, height,
1239- width)`. It defaults to the `image_data_format` value found in your
1240- Keras config file at `~/.keras/keras.json`. If you never set it, then
1241- it will be "channels_last".
1239+ width)`. When unspecified, uses `image_data_format` value found in
1240+ your Keras config file at `~/.keras/keras.json` (if exists) else
1241+ 'channels_last'. Defaults to "channels_last".
12421242 validation_split: Float. Fraction of images reserved for validation
12431243 (strictly between 0 and 1).
12441244 dtype: Dtype to use for the generated arrays.
@@ -1580,70 +1580,71 @@ def flow_from_directory(
15801580 """Takes the path to a directory & generates batches of augmented data.
15811581
15821582 Args:
1583- directory: string, path to the target directory. It should contain
1584- one subdirectory per class. Any PNG, JPG, BMP, PPM or TIF images
1585- inside each of the subdirectories directory tree will be included
1586- in the generator. See [this script](
1587- https://gist.github.com/fchollet/0830affa1f7f19fd47b06d4cf89ed44d)
1588- for more details.
1589- target_size: Tuple of integers `(height, width)`, defaults to `(256,
1590- 256)`. The dimensions to which all images found will be resized.
1591- color_mode: One of "grayscale", "rgb", "rgba". Default: "rgb".
1592- Whether the images will be converted to have 1, 3, or 4 channels.
1593- classes: Optional list of class subdirectories (e.g. `['dogs',
1594- 'cats']`). Default: None. If not provided, the list of classes
1595- will be automatically inferred from the subdirectory
1596- names/structure under `directory`, where each subdirectory will be
1597- treated as a different class (and the order of the classes, which
1598- will map to the label indices, will be alphanumeric). The
1599- dictionary containing the mapping from class names to class
1600- indices can be obtained via the attribute `class_indices`.
1601- class_mode: One of "categorical", "binary", "sparse",
1602- "input", or None. Default: "categorical".
1603- Determines the type of label arrays that are returned:
1604- - "categorical" will be 2D one-hot encoded labels,
1605- - "binary" will be 1D binary labels,
1606- "sparse" will be 1D integer labels,
1607- - "input" will be images identical
1608- to input images (mainly used to work with autoencoders).
1609- - If None, no labels are returned
1610- (the generator will only yield batches of image data,
1611- which is useful to use with `model.predict_generator()`).
1612- Please note that in case of class_mode None,
1613- the data still needs to reside in a subdirectory
1614- of `directory` for it to work correctly.
1615- batch_size: Size of the batches of data (default: 32).
1616- shuffle: Whether to shuffle the data (default: True) If set to
1617- False, sorts the data in alphanumeric order.
1618- seed: Optional random seed for shuffling and transformations.
1619- save_to_dir: None or str (default: None). This allows you to
1620- optionally specify a directory to which to save the augmented
1621- pictures being generated (useful for visualizing what you are
1622- doing).
1623- save_prefix: Str. Prefix to use for filenames of saved pictures
1624- (only relevant if `save_to_dir` is set).
1625- save_format: one of "png", "jpeg", "bmp", "pdf", "ppm", "gif",
1626- "tif", "jpg" (only relevant if `save_to_dir` is set). Default:
1627- "png".
1628- follow_links: Whether to follow symlinks inside
1629- class subdirectories (default: False).
1630- subset: Subset of data (`"training"` or `"validation"`) if
1631- `validation_split` is set in `ImageDataGenerator`.
1632- interpolation: Interpolation method used to resample the image if
1633- the target size is different from that of the loaded image.
1634- Supported methods are `"nearest"`, `"bilinear"`, and `"bicubic"`.
1635- If PIL version 1.1.3 or newer is installed, `"lanczos"` is also
1636- supported. If PIL version 3.4.0 or newer is installed, `"box"` and
1637- `"hamming"` are also supported. By default, `"nearest"` is used.
1638- keep_aspect_ratio: Boolean, whether to resize images to a target
1639- size without aspect ratio distortion. The image is cropped in
1640- the center with target aspect ratio before resizing.
1583+ directory: string, path to the target directory. It should contain
1584+ one subdirectory per class. Any PNG, JPG, BMP, PPM or TIF images
1585+ inside each of the subdirectories directory tree will be included
1586+ in the generator. See [this script](
1587+ https://gist.github.com/fchollet/0830affa1f7f19fd47b06d4cf89ed44d)
1588+ for more details.
1589+ target_size: Tuple of integers `(height, width)`. The dimensions to
1590+ which all images found will be resized. Defaults to `(256,256)`.
1591+ color_mode: One of "grayscale", "rgb", "rgba". Default: "rgb".
1592+ Whether the images will be converted to have 1, 3, or 4 channels.
1593+ classes: Optional list of class subdirectories (e.g. `['dogs',
1594+ 'cats']`). Default: None. If not provided, the list of classes
1595+ will be automatically inferred from the subdirectory
1596+ names/structure under `directory`, where each subdirectory will be
1597+ treated as a different class (and the order of the classes, which
1598+ will map to the label indices, will be alphanumeric). The
1599+ dictionary containing the mapping from class names to class
1600+ indices can be obtained via the attribute `class_indices`.
1601+ class_mode: One of "categorical", "binary", "sparse",
1602+ "input", or None.
1603+ Determines the type of label arrays that are returned:
1604+ - "categorical" will be 2D one-hot encoded labels,
1605+ - "binary" will be 1D binary labels,
1606+ - "sparse" will be 1D integer labels,
1607+ - "input" will be images identical
1608+ to input images (mainly used to work with autoencoders).
1609+ - If None, no labels are returned
1610+ (the generator will only yield batches of image data,
1611+ which is useful to use with `model.predict_generator()`).
1612+ Please note that in case of class_mode None,
1613+ the data still needs to reside in a subdirectory
1614+ of `directory` for it to work correctly.
1615+ Defaults to "categorical".
1616+ batch_size: Size of the batches of data. Defaults to `32`.
1617+ shuffle: Whether to shuffle the data If `False`, sorts the
1618+ data in alphanumeric order. Defaults to `True`.
1619+ seed: Optional random seed for shuffling and transformations.
1620+ save_to_dir: None or str (default: None). This allows you to
1621+ optionally specify a directory to which to save the augmented
1622+ pictures being generated (useful for visualizing what you are
1623+ doing).
1624+ save_prefix: Str. Prefix to use for filenames of saved pictures
1625+ (only relevant if `save_to_dir` is set).
1626+ save_format: one of "png", "jpeg", "bmp", "pdf", "ppm", "gif",
1627+ "tif", "jpg" (only relevant if `save_to_dir` is set).
1628+ Defaults to "png".
1629+ follow_links: Whether to follow symlinks inside
1630+ class subdirectories. Defaults to `False`.
1631+ subset: Subset of data (`"training"` or `"validation"`) if
1632+ `validation_split` is set in `ImageDataGenerator`.
1633+ interpolation: Interpolation method used to resample the image if
1634+ the target size is different from that of the loaded image.
1635+ Supported methods are `"nearest"`, `"bilinear"`, and `"bicubic"`.
1636+ If PIL version 1.1.3 or newer is installed, `"lanczos"` is also
1637+ supported. If PIL version 3.4.0 or newer is installed, `"box"` and
1638+ `"hamming"` are also supported. Defaults to `"nearest"`.
1639+ keep_aspect_ratio: Boolean, whether to resize images to a target
1640+ size without aspect ratio distortion. The image is cropped in
1641+ the center with target aspect ratio before resizing.
16411642
16421643 Returns:
1643- A `DirectoryIterator` yielding tuples of `(x, y)`
1644- where `x` is a numpy array containing a batch
1645- of images with shape `(batch_size, *target_size, channels)`
1646- and `y` is a numpy array of corresponding labels.
1644+ A `DirectoryIterator` yielding tuples of `(x, y)`
1645+ where `x` is a numpy array containing a batch
1646+ of images with shape `(batch_size, *target_size, channels)`
1647+ and `y` is a numpy array of corresponding labels.
16471648 """
16481649 return DirectoryIterator (
16491650 directory ,
0 commit comments