I am new on Pytorch and I was wondering how to decode the labels when using pytorchvision and datasets.ImageFolder.
As far I understood that labels are created with the image folder name

image1102×898 80.9 KB

I have 43 folders so 43 classes that are loaded the folder structure is the following data_img/train/Classes/image_from_classes.
Here is the code line that i have used to load the images:
train_data = datasets.ImageFolder('data_img/train/', transform=train_transforms)
When the model is calculated and that I try to pass an image and predict the result I was expecting the label name however I have a tensor as a return “Image predicted as tensor([15])”.
I was wondering how to decode this number to get the class name?
Thanks for your help,
Samy