I'm having the same issue. I tried the above solution but still got the following error: Invalid input to `zip`. Inputs are expected to be (nested) structures of `tf.data.Dataset` objects but encountered object of type <class 'keras.src.legacy.preprocessing.image.DirectoryIterator'>. Did you ever find a solution?