These artifacts are caused by the normalization.
If you want to get the original image back, you would need to “denormalize” your tensor again:
img = Image.open('PATH')
x = transform(img)

z = x * torch.tensor(std).view(3, 1, 1)
z = z + torch.tensor(mean).view(3, 1, 1)

img2 = transforms.ToPILImage(mode='RGB')(z)
plt.imshow(img2)