The Inference tab in tabs/inference.py displays the normalized image tensor directly without applying inverse normalization before rendering:
img_to_draw = transforms.ToPILImage()(sample_tensor[0])
This causes the output image to appear with distorted, psychedelic colors instead of the original image, making the inference visualization incorrect and misleading. The image tensor should be de-normalized before display so the output image appears correctly with original colours.
Proposed Fix
Add a denormalize helper function in tabs/inference.py and apply it before rendering:
def denormalize(tensor, mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]):
mean = torch.tensor(mean).view(3, 1, 1)
std = torch.tensor(std).view(3, 1, 1)
return torch.clamp(tensor.cpu() * std + mean, 0, 1)
denormalized = denormalize(sample_tensor[0])
img_to_draw = transforms.ToPILImage()(denormalized)
The Inference tab in
tabs/inference.pydisplays the normalized image tensor directly without applying inverse normalization before rendering:This causes the output image to appear with distorted, psychedelic colors instead of the original image, making the inference visualization incorrect and misleading. The image tensor should be de-normalized before display so the output image appears correctly with original colours.
Proposed Fix
Add a
denormalizehelper function intabs/inference.pyand apply it before rendering: