Search code examples
pytorchtensorboarddeeplab

Denormalized image with wrong colors in DeepLabV3 shown in Tensorboard using pytorch


I am trying to print some images using the tensorboard. After reading this link I saw that input images are normalized using mean = [0.485, 0.456, 0.406] and std = [0.229, 0.224, 0.225] but once I try to denormalize them with the following

mean = (0.485, 0.456, 0.406)
std = (0.229, 0.224, 0.225)
mean = torch.Tensor(mean)[None, ..., None, None]
std = torch.Tensor(std)[None, ..., None, None]
return torch.clamp((img * std + mean)*255, 0, 255)

I receive a very strange set of image colors:

enter image description here

And after changing the channels I've got this (the number of rows doesn't matter, that was a change)

enter image description here

When I don't do any normalization, the images are like this

enter image description here

Has anyone had something like this before? I believe I did as I had to do with the normalization but maybe I'm wrong on it


Solution

  • I just realized that there was a transformation from Albumentation related to pixels augmentation. That's why it was not possible to do a simple normalization, since some other transformations related to colors were already applied.