Solved by ptrblck in post #3 
              
              
                Your custom Dataset should work fine. However, currently you could also just use ImageFolder directly without wrapping it in Dataset and pass it to a DataLoader. 
If you want to customize the samples inside __getitem__, your approach looks good!