Calculating mean and std for images?

Hi!
I am new to torchvision and I am trying to normalize my images. I am using transforms.v2.Normalize(). It takes mean and std as parameters. If I have understood it correctly it needs one value for each channel.

I am wondering if you should calculate the mean and std of the pixel distributions over the whole training dataset or for each picture?

Hi
a good practice to use Imagnet Mean and std

Using the mean and std of Imagenet is a common practice. They are calculated based on millions of images. If you want to train from scratch on your own dataset, you can calculate the new mean and std. Otherwise, using the Imagenet pretrianed model with its own mean and std is recommended.