The torchvision datasets are part of the dataset class but they specifically download their own dataset from the web so you cannot use them for different datasets. If you want to create your own dataset you can look at this tutorial here 1 or if your data is in the correct format where each folder is a class you can use the imagefolder class here 2.