| 30 | |
| 31 | |
| 32 | class 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 |
nothing calls this directly
no outgoing calls
no test coverage detected