Often while using ImageDataGenerator from local images, you want to maintain the aspect ratio of the objects itself in order to avoid models to learn the retransformation. This flag allows to maintain original aspect ratio of the objects.
An additional parameter in flow_from_directory is introduced, i.e. train_datagen.flow_from_directory(keep_aspect_ratio=True).
Summary
Often while using
ImageDataGenerator
from local images, you want to maintain the aspect ratio of the objects itself in order to avoid models to learn the retransformation. This flag allows to maintain original aspect ratio of the objects.An additional parameter in
flow_from_directory
is introduced, i.e.train_datagen.flow_from_directory(keep_aspect_ratio=True)
.In
tensorflow
there is https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/smart_resize?hl=en , copied the logic from there, since reuse was not possible due circular import ...Related Issues
https://github.com/keras-team/keras/pull/4987/files
https://stackoverflow.com/questions/42467734/keras-how-to-use-imagedatagenerator-without-deforming-aspect-ratio
PR Overview