Trying to save an Image, somehow It's getting distort

Hi Guys, I’m trying my gan, and I’m trying to save the output as an Image, this is what I’m trying to do:

            path2save = "/workspace/gan_outputs/out_"
            path2save = path2save + str(image_index) + '.png'
            temp_fake = fake.view(fake.shape[0],fake.shape[3],fake.shape[2],fake.shape[1])
            save_fake = temp_fake[0,:,:,:].detach().cpu().numpy()

            save_fake = np.uint8(save_fake)
            save_fake = tensor_2_image(save_fake)
            save_fake.save(path2save)

fake is the ouput of the generator, that I want to visualize.
But the ouput is :
out_20

No matter what the conent is ,My problem that it’s has 9 small duplication, and I cant understand what I did to make it look like this.
(I checked multiple times that my input are correct and not like that)

If you have any Ideas I will be more than happy to hear.
Thanks!

The view operation is probably messing up your image.
It seems you would like to change the axes, thus try to call:

temp_fake = fake.permute(0, 3, 2, 1)
1 Like

Correct! as always…
Thanks!

1 Like