Solved by ptrblck in post #2 
              
              
                The best approach would be to create a custom Dataset as described here and implement the logic to create the target (e.g. by reading them from the image names etc.) manually. 
ImageFolder uses the folder structure to create the class indices, so it wouldn’t be a good fit for your use case (changing…