MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / denormalize

Function denormalize

dzoedepth/utils/misc.py:60–71  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

58
59
60def 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
74class RunningAverageDict:

Callers

nothing calls this directly

Calls 1

toMethod · 0.80

Tested by

no test coverage detected