Reverses the imagenet normalization applied to the input. Args: x (torch.Tensor - shape(N,3,H,W)): input tensor Returns: torch.Tensor - shape(N,3,H,W): Denormalized input
(x)
| 58 | |
| 59 | |
| 60 | def denormalize(x): |
| 61 | """Reverses the imagenet normalization applied to the input. |
| 62 | |
| 63 | Args: |
| 64 | x (torch.Tensor - shape(N,3,H,W)): input tensor |
| 65 | |
| 66 | Returns: |
| 67 | torch.Tensor - shape(N,3,H,W): Denormalized input |
| 68 | """ |
| 69 | mean = torch.Tensor([0.485, 0.456, 0.406]).view(1, 3, 1, 1).to(x.device) |
| 70 | std = torch.Tensor([0.229, 0.224, 0.225]).view(1, 3, 1, 1).to(x.device) |
| 71 | return x * std + mean |
| 72 | |
| 73 | |
| 74 | class RunningAverageDict: |