I would probably not use the ImageFolder dataset, as it would assign a new class label to each subfolder. If I understand your use case correctly, the folders contain the image patches, so you should implement the loading logic in a custom Dataset instead.


You could keep these patches in the current shape and transform them in the __getitem__ of your custom Dataset. Of course, if you could recreate these patches in a constant shape, you could save the processing time during loading, but it depends on your actual use case and if you want to rerun the offline data creation step.