Skip to content

Commit 44c0b83

Browse files
committed
[keras/preprocessing/image.py] Consistent indent of 2 for flow_from_directory docstring ; flow_from_directory defaults-to in docstring
1 parent af5d96a commit 44c0b83

File tree

1 file changed

+63
-62
lines changed

1 file changed

+63
-62
lines changed

keras/preprocessing/image.py

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -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)`. 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. 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

Comments
 (0)