How to visualzie the output of an autoencoder trained on images?

i am training a Denoising AutoEncoder and i want to visualize its outputs. How do i do it
One thing that i noticed is that the model takes in tensors of dtype torch.float32

model.eval()
with torch.no_grad():
    for batch_idx, (imgs, noisy_imgs) in enumerate(val_loader):
        clean_imgs = model(noisy_imgs)
        print(imgs.shape, imgs.dtype)
        print(noisy_imgs.shape, noisy_imgs.dtype)
        print(clean_imgs.shape, clean_imgs.dtype)
torch.Size([4, 1, 64, 256]) torch.float32
torch.Size([4, 1, 64, 256]) torch.float32
torch.Size([4, 1, 64, 256]) torch.float32

Thanks in advance :slight_smile:

If you are using matplotllib, this code should work:

fig, axarr = plt.subplots(clean_imgs.size(0))
for img, ax in zip(clean_imgs, axarr):
    img = img.squeeze(0).numpy()
    ax.imshow(img)
1 Like