Skip to content

Commit

Permalink
fix pynoise code bug (#489)
Browse files Browse the repository at this point in the history
* fix pynoise

* Update custom_train_functions.py for default

* Update custom_train_functions.py for note

* Update custom_train_functions.py for default

* Revert "Update custom_train_functions.py for default"

This reverts commit ca79915d7396ddb57adbeb4b78bafb9a1a884b5c.

* Update custom_train_functions.py for default

* Revert "Update custom_train_functions.py for default"

This reverts commit 483577e137b13933ff24b6ae254f82c0a8d9f1fe.

* default value change
  • Loading branch information
sdbds authored May 11, 2023
1 parent 2767a0f commit 8d562ec
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions library/custom_train_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,14 @@ def get_weighted_text_embeddings(


# https://wandb.ai/johnowhitaker/multires_noise/reports/Multi-Resolution-Noise-for-Diffusion-Model-Training--VmlldzozNjYyOTU2
def pyramid_noise_like(noise, device, iterations=6, discount=0.3):
b, c, w, h = noise.shape
def pyramid_noise_like(noise, device, iterations=6, discount=0.4):
b, c, w, h = noise.shape # EDIT: w and h get over-written, rename for a different variant!
u = torch.nn.Upsample(size=(w, h), mode="bilinear").to(device)
for i in range(iterations):
r = random.random() * 2 + 2 # Rather than always going 2x,
w, h = max(1, int(w / (r**i))), max(1, int(h / (r**i)))
noise += u(torch.randn(b, c, w, h).to(device)) * discount**i
if w == 1 or h == 1:
wn, hn = max(1, int(w / (r**i))), max(1, int(h / (r**i)))
noise += u(torch.randn(b, c, wn, hn).to(device)) * discount**i
if wn == 1 or hn == 1:
break # Lowest resolution is 1x1
return noise / noise.std() # Scaled back to roughly unit variance

Expand Down

0 comments on commit 8d562ec

Please sign in to comment.