How do I find the mean and std of grayscale images using pytorch?

Hey guys, I was wondering if someone could help me with this problem I’m facing. I’m trying to normalize these images in the dataset-

I’m using this project done by someone as reference-

If you go to the transform part of the code he has calculated a set of mean values and std values. He has obtained mean values for three channels (rgb) even though the images are grayscale. How is this possible? Shouldn’t the mean only be one value from 0 to 1?

I tried using code from this video-
Pytorch Quick Tip: Calculate Mean and Standard Deviation of Data (Can’t put the link, sorry)

And when I got my values from this code my images obtained some colour and were no longer grayscale. It seems as if the combination of mean and std values this person (whose project I am using as reference) obtained are perfect because even though they are three rgb values the image remains grayscale. Could someone please help me? Thanks very much!

I’m replying to this to give some more info- This is a link to a stackoverflow question I asked about this which has some of my code in it too- python - Finding the mean and std of pixel values for grayscale images in pytorch - Stack Overflow