Add_image() doesn't work well

i’m using both of save_image() and Summarywriter.add_image()
i made an image from several images. ( N,C,H,W->C,HN,WN)

but i found that MNIST (1,H,W) works well in both, but color image doesn’t work well
here’s the images


the left one is using add_image() (on tensorboard)
and the right one is using save_image() (on my local folder)

스크린샷, 2020-05-25 07-37-51
and also here is the code

i also try changing the order of RGB channel, but it doesn’t work

Thanks

save_image “unnormalizes” the image via:

ndarr = grid.mul(255).add_(0.5).clamp_(0, 255).permute(1, 2, 0).to('cpu', torch.uint8).numpy()

I don’t know, if add_image of TensorBoard does the same, but it looks like the colors might be clipped, so you could try to apply the same method as in save_image.

1 Like

thx i tried some ways, and found why that didn’t work.
i guess in-place operation was problem.

i gave denorm(image) to each function(save_image,add_image) and it works (i.e. save_image(denorm(image))
but when i gave image which is unnormalized to each function it didn’t (i.e. image=denorm(image), save_image(image))