MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / pyramid_noise_like

Function pyramid_noise_like

k_diffusion/utils.py:462–470  ·  view source on GitHub ↗
(noise, iterations=6, discount=0.3)

Source from the content-addressed store, hash-verified

460
461
462def pyramid_noise_like(noise, iterations=6, discount=0.3):
463 b, c, w, h = noise.shape
464 u = torch.nn.Upsample(size=(w, h), mode='bilinear')
465 for i in range(iterations):
466 r = random.random()*2+2 # Rather than always going 2x,
467 w, h = max(1, int(w/(r**i))), max(1, int(h/(r**i)))
468 noise += u(torch.randn((b, c, w, h), device=noise.device)) * discount**i
469 if w==1 or h==1: break # Lowest resolution is 1x1
470 return noise/noise.std() # Scaled back to roughly unit variance

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected