Code snippet does not return any error.
GPU: GTX 2080 , GTX 1080  (Tried on both)
I used ImageFolder before (dataset provided by PyTorch) and I have never face this issue, not too sure what is causing it now.