Hi, I am working with Cityscapes dataset. For normalising the images I used the mean
and std
of Imagenet. After normalising I computed mean
and std
for some images in the dataset. They are roughly close to 0 and 1 but not very close.
For example mean
and std
of one image after normalisation is equal to
mean = [-0.14200746, -0.07835515, -0.09254397]
std = [0.84492135, 0.8451715, 0.849345 ]
Are these values for mean and std of a normalised image acceptable?
I also computed the mean
and std
over the whole dataset using the following snippet:
def compute_mean_std(dataloader):
pop_mean = []
pop_std = []
for i, (img,mask, rgb_mask) in enumerate(dataloader):
numpy_image = img.cpu().numpy()
batch_mean = np.mean(numpy_image,axis=(0,2,3))
pop_mean.append(batch_mean)
batch_std = np.mean(numpy_image, axis=(0,2,3))
pop_std.append(batch_std)
pop_mean = np.array(pop_mean).mean(axis=0)
pop_std = np.array(pop_std).std(axis=0)
return(pop_mean, pop_std)
And I obtained values:
MEAN = [0.28660315, 0.32426634, 0.28302112]
STD = [0.00310452, 0.00292714, 0.00296411]
But again when I normalised images using these values and calculated the mean
and std
of each image the mean
and std
was something like this:
[-7.8684726 -4.747944 -5.4215384]
[47.001762 51.33731 50.00176 ]
I do not know which point I missed. I only know these two ways to normalise images.