title: Pytorch: Image label
body: <p>I am working on an image classifier with 31 classes(Office dataset). There is one folder for each of the classes.  I have a python script written using PyTorch that loads the dataset using <code>datasets.ImageFolder</code> and assigns a label to each image and then trains. Here is my code snippet for loading data:</p>
  
  <pre><code>from torchvision import datasets, transforms
  import torch
  
  def load_training(root_path, dir, batch_size, kwargs):
      transform = transforms.Compose(
          [transforms.Resize([256, 256]),
           transforms.RandomCrop(224),
           transforms.RandomHorizontalFlip(),
           transforms.ToTensor()])
      data = datasets.ImageFolder(root=root_path + dir, transform=transform)
      train_loader = torch.utils.data.DataLoader(data, batch_size=batch_size, shuffle=True, drop_last=True, **kwargs)
      return train_loader
  </code></pre>
  
  <p>The code takes each folder, assigns the same label to all images in that folder. Is there any way to find which label is assigned to which image/image folder? </p>