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

Class AddNoiseLatent

diff2flow/dataset/image_preprocessing.py:32–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31
32class AddNoiseLatent:
33 def __init__(self, key, resolution: int = 512, latent_dim: int = 4):
34 self.key = key
35 assert resolution % 8 == 0, "Resolution must be divisible by 8"
36 self.shape = (latent_dim, resolution // 8, resolution // 8)
37
38 def __call__(self, sample):
39 assert self.key not in sample, f"Key {self.key} already exists in sample"
40 noise = torch.randn(self.shape)
41 sample[self.key] = noise
42 return sample

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected