you can use ImageFolder, or you can simply copy the Dataset files https://github.com/pytorch/vision/tree/master/torchvision/datasets 188 , modify them for your own purpose and used the modified versions.