Why do I get washedout images when displaying make_grid output?

Hello everyone.
Today I faced something strange. When using torchvision.utils.make_grid(), I noticed when ever I display the resulting image in matplotib, the image is washedout! but when I save it using save_img , it turns out just fine.
This is how it looks when I display the output of make_grid() in matplotlib :

and this is how it got saved to the disk :
and this is the snippet I wrote :

from` torchvision.utils` import save_image, make_grid

fig = plt.figure(figsize=(28, 28))
for i in range(5):
  grid_imgs = make_grid(torch.from_numpy(img_pairs[i]),
  ax = fig.add_subplot(5, 1, i+1, xticks=[], yticks=[])

normalizing and not doesnt affect anything.
What am I missing here ?
Your kind help is greatly appreciated

1 Like

I think removing ax = … and using plt.imshow(…) instead of ax.imshow(…) could work.

Thanks thats not the case, since I have several images to display I needed as many axes so I need to use that.

Thanks to dear God, I found the cause!
This was caused by save_image() method! I moved the save_image() after showing the image and all was fine!
This seems like a bug to me. this should not happen at all! @smth

Thanks for raising this bug!
I’ve created an issue here to track and fix it.

1 Like

Fixed here. Should be available in the nightly builds.

1 Like