The advantage of using an ImageFolder is that you are loading PIL.Images and can apply all torchvision transformations on them directly (without transforming the binary data back to an image).
Although the MNIST dataset is saved as binary images, each image is converted back to a PIL.Image as seen in this line of code 4 so that the output is consistent throughout all datasets.
Do you see any unusual CPU and RAM usage using ImageFolder?