Load csv file in pytorch

I am newbie to PyTorch , I am doing image classification with PyTorch. I have a separate Images folder and train and test csv file with images ids and labels . I don’t have any an idea about how to combine those images and ID and converting into tensors.

  1. train.csv : contains all ID of Image like 4325.jpg, 2345.jpg,…so on and contains another column of name “Labels” contains cat , dog.
  2. Image_data : contains all the images of with ID name.

Depends if it’s multilabel classification or not.
If so, you would have to split the column and transform into one-hot encoded vector. You would also have to use BCELoss (Binary Cross Entropy) because your problem has multiple classes for a single example.

If it’s single-label per image, then you can just use pandas and convert the column with label into a categorical variable, which you can then convert into numbers.

1 Like