Coil-20 dataset

Any hints on how to use COIL-20 dataset in pytorch? I have downloaded the dataset. But how to change it in train_loader and test_loader

Maybe this discussion will help:

Not the MAT file. Is there a way to use it directly with images iteself ?

You can create your own data loader for this dataset. Have a look at this tutorial - Data Loading and Processing Tutorial

@viraat I don’t have a csv file. I just have images. And do I need to create target/labels manually. It is a tedious task.

That’s fine - you can still load images without a CSV file by iterating over the available files in the directory using os.listdirs. I’m not familiar with the COIL 20 dataset but if the filenames contain the labels/targets you could extract them using regex.

Have a look at the source for ImageFolder and DataFolder here.

@viraat I need to create train_loader and test_loader similar to torchvision. Actually I am creating a framework wherein I return train and test loader for the dataset specified in the command line arguments. Can you help with that?

Do you have separate datasets for train and test? Or are you splitting one dataset into training and testing sets? If you are splitting one dataset into two you have to use the RandomSubSampler as the sampler argument of torch.utils.data.DataLoader.

Before that you would want to get a train loader. For that you use dataloader to get an iterator over the dataset. The dataloader class takes in a dataset object along with other parameters to return an iterator.

So your steps would be

  • create a custom dataset implementation
  • load that dataset using dataloader

Details about the dataset class in the tutorial are here.
Details about how you iterate through the data using a dataloader are here.

I do not know how your data is structured or about the COIL-20 dataset. Without that I can’t provide you specific help on how to do it. You should be able to follow along the tutorial to create a dataset class which can be used with torch.utils.data.DataLoader iterator.

@viraat
That’s the dataset I am talking about.
http://www.cs.columbia.edu/CAVE//software/softlib/coil-20.php

It has grayscale images belonging to 20 categories.