Image normalization in Pytorch or tensorflow

Hi there,

Does anyone know how to replicate the same normalization with Imagenet stats that Fastai’s dataloader does ?

In you find imagenet_stats = ([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])

Which means the first 3 is the mean of the RGB images and the second 3 is the standard deviation.

You can do (x - mean) / stddev to normalize then.

Edit: You will also find the normalize function in the module btw.