For future reference:
I have used this from https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py 489 to find the mapping-
def find_classes(dir):
    classes = os.listdir(dir)
    classes.sort()
    class_to_idx = {classes[i]: i for i in range(len(classes))}
    return classes, class_to_idx