Search code examples
pythontensorflowkerasdeep-learning

Keras2 ImageDataGenerator or TensorFlow tf.data?


With Keras2 being implemented into TensorFlow and TensorFlow 2.0 on the horizon, should you use Keras ImageDataGenerator with e.g, flow_from_directory or tf.data from TensorFlow which also can be used with fit_genearator of Keras now?

Will both methods will have their place by serving a different purpose or will tf.data be the new way to go and Keras generators deprecated in the future?

Thanks, I would like to take the path which keeps me up to date a bit longer in this fast moving field.


Solution

  • Update 2022

    On visiting the ImageDataGenerator documentation, there is now a deprecation message that says the following:

    Deprecated: tf.keras.preprocessing.image.ImageDataGenerator is not recommended for new code. Prefer loading images with tf.keras.utils.image_dataset_from_directory and transforming the output tf.data.Dataset with preprocessing layers. For more information, see the tutorials for loading images and augmenting images, as well as the preprocessing layer guide.