junyanz / pytorch-CycleGAN-and-pix2pix

Image-to-Image Translation in PyTorch
Other
23.09k stars 6.32k forks source link

Inverse normalisation before displaying/saving images? #1591

Closed MihaelaCroitor closed 1 year ago

MihaelaCroitor commented 1 year ago

Hi! I am using pix2pix model and have a few questions about it. I noticed that the original image and ground truth are normalized before passing to the model and that the last activation function of the generator is Tanh. Is there any inverse normalisation applied to the images before they are displayed/saved, and if so in which part of the code is this done? I am trying to remove the normalisation so I have ground truth images with input in the range of 0-1 and apply a sigmoid activation layer in the last layer of the UNet256 generator. At the moment, the images displayed in the server have a gray color, but you can see the structures in the image. I assume it must be the inverse of the normalisation. I am trying to remove that, so please let me know where it is.

MihaelaCroitor commented 1 year ago

Figured it out. I modified the function tensor2im from util.py https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/master/util/util.py#L9 Modified the transformation to : image_numpy = (np.transpose(image_numpy, (1, 2, 0)) ) * 255