Hi, I use torchvision.transform to transform the image as
normalize = transforms.Normalize(mean=[0.5,0.5,0.5],std=[0.5,0.5,0.5])
transform = transforms.Compose(
The images are in the range of [-1,1], whereas I need the range to be in [0,1].
Any help or clue would be appreciated, thank you.
I guess this has to be
You can refer to this post:
To renormalize the image, you can use
I have no idea, but saving Images normalize at mean=0,SD=1 are blurry.
can you paste the exact code that you are using?
Once I do normaization, I load the images using loader_image, and loader_2nsimage, after working on image, it is saved using following comand, where first image is original image from loader
pic = (torch.cat([original_image_A,original_image_B], dim=0).data + 1) / 2.0
save_dir = './img4_1/'
torchvision.utils.save_image(pic, '%s/Epoch_(%d)_(%dof%d).jpg' % (save_dir, epoch, i + 1, min(len(loader_image), len(loader_2ndimage))), nrow=3)
The saved images are good when saved using normalization of mean=05, sd=1 or any other, but using 0,1 makes it blurry.
I’m not sure what you mean by this. can you please elaborate?
# step 1: convert it to [0 ,2]
tensor_image = tensor_image +1
# step 2: convert it to [0 ,1]
tensor_image = tensor_image - tensor_image.min()
tensor_image_0_1 = tensor_image / (tensor_image.max() - tensor_image.min())