Question of Imagefolder using custom image dataset

It’s the simple Question.
I got a 5 class folder and each have many images.
So I use the Imagefolder, but list type output using the many CPU and RAM.
I want to change this format to tensor like MNIST dset.
How can I change this?
Please help me T.T

Up : My dataset
Down : MNIST dataset

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 so that the output is consistent throughout all datasets.

Do you see any unusual CPU and RAM usage using ImageFolder?