I think the best approach would still be to write a custom Dataset and read the images from their path by using e.g. PIL.Image.open. In fact, the ImageFolder does the same as seen here 28.
I don’t know how the targets are created, but I assume you could either create or load them using the same index as used for the image paths.