diff --git a/keras_preprocessing/image/directory_iterator.py b/keras_preprocessing/image/directory_iterator.py index 0911eaef..280021bc 100644 --- a/keras_preprocessing/image/directory_iterator.py +++ b/keras_preprocessing/image/directory_iterator.py @@ -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} @@ -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, @@ -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 = [ diff --git a/keras_preprocessing/image/image_data_generator.py b/keras_preprocessing/image/image_data_generator.py index e3c29383..05ad6623 100644 --- a/keras_preprocessing/image/image_data_generator.py +++ b/keras_preprocessing/image/image_data_generator.py @@ -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 @@ -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)` @@ -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,