How to load all images using image_dataset_from_directory function?
You don't actually need to apply the class labels, these don't matter. Keras will detect these automatically for you. It does this by studying the directory your data is in. Make sure you point to the parent folder where all your data should be. Your data should be in the following format:
my_data/
...BacterialSpot/
...EarlyBlight/
...Healthy/
...LateBlight/
...Tomato/

where the data source you need to point to is my_data. Here is an implementation:
train = tf.keras.preprocessing.image_dataset_from_directory(
  'my_data',
  validation_split=0.2,
  subset=&quot;training&quot;,
  image_size=(128, 128),
  batch_size=128)

val = tf.keras.preprocessing.image_dataset_from_directory(
  'my_data',
  validation_split=0.2,
  subset=&quot;validation&quot;,
  image_size=(128, 128),
  batch_size=128)

Then when you run it:
Found 3647 files belonging to 1 classes.
Using 2918 files for training.
Found 3647 files belonging to 1 classes.
Using 729 files for validation.

Keras has detected the classes automatically for you. I have used only one class in my example so you should be able to see something relating to 5 classes for yours. See an example implementation here by Google:
https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/images/classification.ipynb#scrollTo=iscU3UoVJBXj