I am working on a GAN and cannot make it work to save images that I transformed into tensors back to “normal” pngs within a loop. The same goes for the tensors that are generated by the Generator.
I applied the following transformation for the original images I am using for the training in the GAN ( I hope i did it the right way):
transform = transforms.Compose(
transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
When trying to save the tensors as png images in a loop with the following code they do not come out the right way:
real_samples = next(iter(train_loader))
for i in range(4):
torchvision.utils.save_image(real_samples[i, :, :, :],
On the left is an example of the original image after transformation and on the right an example of the “wrongly” saved ones:
Can anyone please help me out with saving the images in the right way?