To Tensor transform is messing my images?

ToTensor permutes the array and returns a tensor in the shape [C, H, W]. Using reshape to swap the order of dimensions is wrong and will interleave the image as is seen in your last output:

        # torch tensor
        torch_ten = to_tensor(img)
        print("torch_tensor shape:", torch_ten.shape)
        print(torch_ten.numpy().shape)
        plt.imshow(torch_ten.numpy().reshape(h, w, c))

use plt.imshow(torch_ten.permute(1, 2, 0).numpy()) and it should work.

2 Likes