so I have a tensor CxHxW = 3x480x640 and would like to save it as a png file to disk. However,
utils.save_image(img, “./img.png”)
yields strange, white-dominated images and I suspect some form of scaling or no executed permutation of the tensor, so that the channel is the last dimension. But if I try to permute the tensor prior to saving it
the expanded size of the tensor (640) must match the existing size (3) at son-singleton dimension 2. Target sizes [3, 480,640] Tensor sizes [480,640,3]
If I do
img = img.detach().cpu().numpy()
pic = np.transpose(img, (1, 2, 0))
imsave("img.png", img)
the image is saved correctly. Do I have to change something in the function call to save_image?
edit: if I put
normalize = True
in the function call, it works, but I dont get why. The image is uint8 with 3 channels, and if I set normalize to true, it ought to scale the values in the within the interval [0,1]. Also this official example baffles me. In line 7 and 8, are normalize = true and range = (0,1) not the same?