John_J_Watson:

So, dataset.classes does return folder names, but when I loop through ds , the target is showing me indices of  dataset.classes rather than the folder name 
To the NN I would pass the sample and the target(which here is the folder name), not the indices, right?


That is expected and the target should contain the class indices, not the names.
So e.g. for three folders your target should contain values in [0, 1, 2] 
These target values are used to index the output of the model during the loss calculation, so they are used as numerical values instead of the folder names.