If you want to use image_dataset_from_directory, you should put every file in class subfolder.
Or you can create dataset using tf.data
  
      

      TensorFlow
  

  
    

tf.data: Build TensorFlow input pipelines  |  TensorFlow Core 3