'Denormalize images from [0 1] to [0 255]
after performing this during inferencing/testing:
output = model(image)
output = output.cpu().detach().numpy()
output = np.squeeze(output , axis = 0)
I tried to denormalize the output by using my own function:
def Denormaliser3Channel (image):
image = image.swapaxes(2,0) # <--- from (Channel, H, W) to (H, W, Channel)
mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]
image = image*std
image = image + mean
image = (image)*255.
return image
after using the function, this is the result of the image array:
[[[126.09467533 120.49761354 95.68051658]
[126.04139193 120.18946077 95.76008117]
[126.0490471 120.06061473 95.65981557]
...
what operations do I need to perform/missing so that the output is in int? such as:
[[[126 120 95]
[126 120 95]
[126 120 95]
...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
