How to use my own images instead of the CIFAR10 dataset

Hi!

I know I’m asking something very basic but I cannot find the answer myself, apologies if it is already answered here. I have been playing with this tutorial: https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html . This is actually what I want to do myself but, naturally, for my own dataset. So, how can I use my own images instead of the CIFAR10 dataset?

Thanks in advance!

CIFAR10 is just an implementation of a torch.util.data.Dataset, and such a dataset needs only two methods: __len__ and __getitem__, as can be seen here: https://github.com/pytorch/vision/blob/master/torchvision/datasets/cifar.py
Copy what you need from the CIFAR10 implementation and change the source of the data to be your images.

1 Like