The ImageFolder creation should be in the __init__ and in __getitem__ you would index the ImageFolder.
Alternatively, you could also load the images manually using a list of image paths in __getitem__.