MCPcopy Create free account
hub / github.com/CompVis/diff2flow / preprocess

Method preprocess

diff2flow/conditioning/encoders.py:42–48  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

40 self.uncond = None
41
42 def preprocess(self, x):
43 # resize to 224, normalize to [0,1] and re-normalize according to clip
44 x = torch.nn.functional.interpolate(x, size=(224, 224), mode='bilinear', align_corners=False)
45 assert x.min() >= -1. and x.max() <= 1.
46 x = (x + 1.) / 2.
47 x = (x - self.mean.reshape(1,-1,1,1)) / self.std.reshape(1,-1,1,1)
48 return x
49
50 def forward(self, x, no_dropout=False):
51 # x is assumed to be in range [-1,1]

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected