MCPcopy Create free account
hub / github.com/CSAILVision/gandissect / ReverseNormalize

Class ReverseNormalize

netdissect/dissection.py:1492–1503  ·  view source on GitHub ↗

Applies the reverse of torchvision.transforms.Normalize.

Source from the content-addressed store, hash-verified

1490 return None
1491
1492class ReverseNormalize:
1493 '''
1494 Applies the reverse of torchvision.transforms.Normalize.
1495 '''
1496 def __init__(self, mean, stdev):
1497 mean = numpy.array(mean)
1498 stdev = numpy.array(stdev)
1499 self.mean = torch.from_numpy(mean)[None,:,None,None].float()
1500 self.stdev = torch.from_numpy(stdev)[None,:,None,None].float()
1501 def __call__(self, data):
1502 device = data.device
1503 return data.mul(self.stdev.to(device)).add_(self.mean.to(device))
1504
1505class ImageOnlySegRunner:
1506 def __init__(self, dataset, recover_image=None):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected