Pytorch: Testing With Torchvision.datasets.imagefolder And Dataloader
Solution 1:
Looking at the data from Kaggle and your code, it seems that there are problems in your data loading, both train and test set. First of all, the data should be in a different folder per label for the default PyTorch ImageFolder
to load it correctly. In your case, since all the training data is in the same folder, PyTorch is loading it as one class and hence learning seems to be working. You can correct this by using a folder structure like - train/dog
, - train/cat
, - test/dog
, - test/cat
and then passing the train and the test folder to the train and test ImageFolder
respectively. The training code seems fine, just change the folder structure and you should be good. Take a look at the official documentation of ImageFolder which has a similar example.
Post a Comment for "Pytorch: Testing With Torchvision.datasets.imagefolder And Dataloader"