Unfortunately, I have to use the original transformation I referenced.
Is there norm() function in your code torch.norm()? I just added:
x_norm = norm(img)
x = x_norm * torch.tensor([0.229, 0.224, 0.225])[:, None, None] + torch.tensor([0.485, 0.456, 0.406])[:, None, None]

in my code before ToPILImage() yet this yields an image which is just entirely blue. Sorry for all this back and forth. I’m still unsure why I’m not getting the expected output…