Pytorch: Image label
The class ImageFolder has an attribute class_to_idx
which is a dictionary mapping the name of the class to the index (label). So, you can access the classes with data.classes
and for each class get the label with data.class_to_idx
.
For reference: https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py