Hey,
I am using a pretrained network and wanted to normalize my images according to the ImageNet.
For some reason however the images look really weird after the normalization.
Hi,
As you are using custom mean and std, I think the proper approach of unnormalization would be to unnormalize using those mean and stds. Please see this thread: Simple way to inverse transform ? Normalization
Hi,
For me the point is he want to visualize the images after normalizing. It’s not possible due to the format they use but you can keep the normalization and remap it.
Unnormalize is indeed returning the original image.
Yes, the reason that I suggested that approach is that it will give the statistics similar original images in the dataset, meanwhile it might not be necessary for visualization purposes.
If you want to just scale your input in range of [0, 1], transforms.ToTensor will do the job. If you need to compute z-score you can use transforms.Normalize.
As you have mentioned you are using pretrained network, you may want to normalize them. Unnormalization is used for viewing the transformed images or when your model predicts an image which usually is normalized output.
Just note that when you are using transforms.Normalize, you are using z-score, so the output will not be in range [0, 1]. It depends on the mean and std but if you set mean and std = 0.5 for all channels it will be in [-1, 1], otherwise, out of this range.
You can find the proper input from the implementation of pretrained model, but usually, you will find normalization based on ImageNet values.