PyTorch: Dogs vs Cat dataset with datasets.ImageFolder
I am new on PyTorch trying to create a TransferLearning model.
I am using dogs vs cats dataset from Kaggle.
I am using ImageFolder to load the data and it requires a folder for each classes. But the photos in the test folder are mixed.So I'm not able to separate the images on the test folder. What can I do to solve the problem apart from labeling all the test data with my hand?

You can create a custom Dataset class and wrap it inside a dataloader in Pytorch.
This link has great information on this topic
An overall structure to follow is
class Dog_and_Cat():
  def __init__(self, ...):
    ... # replace with a zipped list of image paths and labels (Cat or Dog)
    # You can use glob.glob
    # Overall ask how do I know the label of the image and install that reasoning in code
    # result is a zipped list like [(&quot;img1.jpg&quot;, 0), (&quot;img2.jpg&quot;, 1)] where 0 and 1 represent Cat and Dog

  def __getitem__(self, idx): 
    #describe the func when indexing your class. This is where you open your image and do transforms and return it. 

  def __len__(self):
   # This is where you describe the length of the dataset. 
   # Ideally should return len of zipped list mentioned above. 


You can init this class you just made instead of Image Folder and then put an object of that class inside the dataloader. This will solve your task
Sarthak
