image_dataset_from_directory VS flow_from_directory
tf.keras.preprocessing.image_dataset_from_directory
Generates a tf.data.Dataset from image files in a directory.


ImageDataGenerator.flow_from_directory
Takes the path to a directory &amp; generates batches of augmented data.

While their return type also differs but the key difference is that flow_from_directory is a method of ImageDataGenerator while image_dataset_from_directory is a preprocessing function to read image form directory.
image_dataset_from_directory will not facilitate you with augmented image generation capability on-the-fly.


which one should I use?

It's quite common to generate augmented images when working with CNN, so better to use flow_from_directory.
If you do not need augmented image, you may control the same by the parameters of ImageDataGenerator
Reference - Keras docs