Mapping of image with class label

Hey. I am completely new to PyTorch and have no idea where to begin with. I am working on a classification problem. It’s a 4 class classification problem. I have all the images in a single folder. I have a .csv file of the one-hot encoded representation corresponding to each image
ground_truth_labels
. The column name represents the actual class and rows contain corresponding one hot encoded representation like this [0 0 0 1]. How to map this representation with images?

If I map these things, then how would it be ensured that the images are passed with their corresponding labels to the neural network? Can someone please give me idea about how to proceed?

If you want to train with CrossEntropyLoss, you can define a simple dataset like

class MyDataset(Dataset):
    def __init__(self, mapping):
        self.mapping = {filename : mapping[filename].index(1) for filename in mapping}
        self.filenames = self.mapping.keys()
        self.len = len(mapping)

    def __len__(self):
        return self.len

    def __getitem__(self, idx):
        return Image.open(self.filenames[idx]), self.mapping[self.filenames[idx]]

The ImageNet example: examples/main.py at master · pytorch/examples · GitHub is a good reference for how to train a classification model.