How to get the class names to class label mapping
I am using ResNet-18 for classification purpose. I have used dataloader to load the data. But how get the label to class name mapping? Does it load in alphabetical order?
avijit_dasgupta
For future reference: <SCODE>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<ECODE>
avijit_dasgupta
zym1010
Something like this: <SCODE>dataset = datasets.ImageFolder(data_folder, transform=data_transforms)
print(dataset.class_to_idx)
<ECODE>
Ray_Luo
vipin14119