The MNIST dataset doesn’t convert the images to RGB, but to a grayscale image. Have a look at this line of code 763.
I assume you are using the MNIST data with another color image set?
If so, you could check in __getitem__, if it’s already a color image, and if not use my second approach to convert it.