Saving GAN generated images

Torchvision has a function called save_image(). Here is the documentation.

You might want to take a look at this old discussion to see some examples.

Here is also a minimal example.

from torchvision.utils import save_image

# Batch x Channel x Height x Width = BxCxHxW = 64x3x28x28
rand_tensor= torch.rand(64, 3,28,28) 

# Taking the first image from the batch (B)
# Img size CxHxW
img1 = rand_tensor[0]           
save_image(img1, 'img1.png')
1 Like