From 8d562ecf48d3cea64dda509a033423e17b91c2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=92=E9=BE=8D=E8=81=96=E8=80=85=40bdsqlsz?= Date: Thu, 11 May 2023 20:48:51 +0800 Subject: [PATCH] fix pynoise code bug (#489) * 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 --- library/custom_train_functions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/custom_train_functions.py b/library/custom_train_functions.py index 2d387d15..0c527c35 100644 --- a/library/custom_train_functions.py +++ b/library/custom_train_functions.py @@ -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