I didn’t use your whole code. Just copied your approach to add some custom solutions in ImageFolder() source code. In my case, I added numpy.shuffle() in ImageFolder() and changed a little bit default loader.