How to do image resizing with bilinear interpolation using torch tensor on CUDA?

Your output might be clipped to [0, 1], if you are trying to visualize floating point numbers or [0, 255] if you are using uint8.
I cannot reproduce the issue using the latest stable releases and by making sure I’m casting to the expected type:

img = PIL.Image.open('drums.png')
img_arr = np.array(img)[:, :, :3] # remove alpha channel
plt.imshow(img_arr)

x = torch.from_numpy(img_arr).permute(2, 0, 1).unsqueeze(0).float()

out1 = F.interpolate(x, size=(200, 200))
out2 = F.interpolate(x, size=(200, 200), mode='bilinear')

plt.imshow(out1[0].permute(1, 2, 0).byte().numpy())
plt.imshow(out2[0].permute(1, 2, 0).byte().numpy())

Original
image

out1
image

out2
image

1 Like