Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Adding verbosity arg to ImageDataGenerator.flow_from_directory #350

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions keras_preprocessing/image/directory_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class DirectoryIterator(BatchFromFilesMixin, Iterator):
without aspect ratio distortion. The image is cropped in the center
with target aspect ratio before resizing.
dtype: Dtype to use for generated arrays.
verbose: 1 or 0. Defaults to 1. 0=silent mode,
1=prints total number of samples and classes.
"""
allowed_class_modes = {'categorical', 'binary', 'sparse', 'input', None}

Expand Down Expand Up @@ -89,7 +91,8 @@ def __init__(self,
subset=None,
interpolation='nearest',
keep_aspect_ratio=False,
dtype='float32'):
dtype='float32',
verbose=1):
super(DirectoryIterator, self).set_processing_attrs(image_data_generator,
target_size,
color_mode,
Expand Down Expand Up @@ -141,8 +144,11 @@ def __init__(self,
self.classes[i:i + len(classes)] = classes
i += len(classes)

print('Found %d images belonging to %d classes.' %
(self.samples, self.num_classes))
if verbose == 0:
pass
else :
print('Found %d images belonging to %d classes.' %
(self.samples, self.num_classes))
pool.close()
pool.join()
self._filepaths = [
Expand Down
8 changes: 6 additions & 2 deletions keras_preprocessing/image/image_data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ def flow_from_directory(self,
follow_links=False,
subset=None,
interpolation='nearest',
keep_aspect_ratio=False):
keep_aspect_ratio=False,
verbose=1):
"""Takes the path to a directory & generates batches of augmented data.

# Arguments
Expand Down Expand Up @@ -511,6 +512,8 @@ class subdirectories (default: False).
keep_aspect_ratio: Boolean, whether to resize images to a target
size without aspect ratio distortion. The image is cropped in
the center with target aspect ratio before resizing.
verbose: 1 or 0. Defaults to 1. 0=silent mode,
1=prints total number of samples and classes.

# Returns
A `DirectoryIterator` yielding tuples of `(x, y)`
Expand All @@ -536,7 +539,8 @@ class subdirectories (default: False).
follow_links=follow_links,
subset=subset,
interpolation=interpolation,
dtype=self.dtype
dtype=self.dtype,
verbose=verbose
)

def flow_from_dataframe(self,
Expand Down