Thanks for this. In my DataLoader I have the following code. Can this be modified to reflect the above:
   def __getitem__(self, idx):
        path = self.files[idx]
        sample = Image.open(path)
        #transform3 = Grayscale(num_output_channels=3)
        #sample = transform3(sample) # convert to a 3 channel grayscale, as it needs to be 3 channel.
        if self.transform:
            sample = self.transform(sample)


Thanks