From 8316a002da5937a34535061453c348e681035143 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Mon, 21 Nov 2022 17:11:38 +0530 Subject: [PATCH 01/22] Don't warn about whitespace in the git patch application --- scripts/on_sd_start.bat | 4 ++-- scripts/on_sd_start.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 79a51205..c0fe4a64 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -37,8 +37,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @call git pull @call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - @call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch - @call git apply --whitespace=fix ..\ui\sd_internal\env_yaml.patch + @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch + @call git apply --whitespace=nowarn ..\ui\sd_internal\env_yaml.patch @cd .. ) else ( diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index a4f92428..903e7e44 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -30,8 +30,8 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta git pull git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" - git apply --whitespace=fix ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" + git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply --whitespace=nowarn ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" cd .. else From eef9af2266a7236b96eeb1b8a81db2f2bd427188 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Mon, 21 Nov 2022 17:14:34 +0530 Subject: [PATCH 02/22] Typo --- scripts/on_sd_start.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index c0fe4a64..6f5ab212 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -20,7 +20,7 @@ call conda activate @rem @echo. & echo "Error activating conda for Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. @rem pause @rem exit /b -@rem) +@rem ) @REM remove the old version of the dev console script, if it's still present if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" From 3bf5e11f94b9e71ff124a9df6660444603dea9e6 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Mon, 21 Nov 2022 17:19:55 +0530 Subject: [PATCH 03/22] Nowarn for fresh installation (git apply whitespace) --- scripts/on_sd_start.bat | 4 ++-- scripts/on_sd_start.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 6f5ab212..1acb7b3a 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -55,8 +55,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @cd stable-diffusion @call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - @call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch - @call git apply --whitespace=fix ..\ui\sd_internal\env_yaml.patch + @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch + @call git apply --whitespace=nowarn ..\ui\sd_internal\env_yaml.patch @cd .. ) diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 903e7e44..7745855a 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -46,8 +46,8 @@ else cd stable-diffusion git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" - git apply --whitespace=fix ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" + git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply --whitespace=nowarn ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" cd .. fi From 6dc99e676e2f69312657fa8a8d407ce7813b30a2 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Mon, 21 Nov 2022 18:42:07 +0530 Subject: [PATCH 04/22] Reduce the width of the editor sidebar, regression --- ui/media/css/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/media/css/main.css b/ui/media/css/main.css index a2cf8b38..0cf83302 100644 --- a/ui/media/css/main.css +++ b/ui/media/css/main.css @@ -515,7 +515,7 @@ img { } #editor-settings { - min-width: 500px; + min-width: 350px; } #editor-settings-entries { From 9c71c966ca5d21cb13f96ed60848570defe1e240 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 10:39:47 +0530 Subject: [PATCH 05/22] Shell error code check --- scripts/bootstrap.bat | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/bootstrap.bat b/scripts/bootstrap.bat index 7d067cc3..cb0909d0 100644 --- a/scripts/bootstrap.bat +++ b/scripts/bootstrap.bat @@ -42,11 +42,11 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( mkdir "%MAMBA_ROOT_PREFIX%" call curl -Lk "%MICROMAMBA_DOWNLOAD_URL%" > "%MAMBA_ROOT_PREFIX%\micromamba.exe" - @REM if "%ERRORLEVEL%" NEQ "0" ( - @REM echo "There was a problem downloading micromamba. Cannot continue." - @REM pause - @REM exit /b - @REM ) + if "%ERRORLEVEL%" NEQ "0" ( + echo "There was a problem downloading micromamba. Cannot continue." + pause + exit /b + ) mkdir "%APPDATA%" mkdir "%USERPROFILE%" From 87a7b70a27fe77e4cedc262fce57e0a7cef34f31 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 10:40:20 +0530 Subject: [PATCH 06/22] Shell error code check --- scripts/on_sd_start.bat | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 1acb7b3a..f1b459cb 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -16,11 +16,11 @@ if exist "%cd%\profile" ( @rem activate the installer env call conda activate -@rem @if "%ERRORLEVEL%" NEQ "0" ( -@rem @echo. & echo "Error activating conda for Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. -@rem pause -@rem exit /b -@rem ) +@if "%ERRORLEVEL%" NEQ "0" ( + @echo. & echo "Error activating conda for Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b +) @REM remove the old version of the dev console script, if it's still present if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" From ff3ca8b36b8a48ec521be006acd26f0e6a4bd58e Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 10:48:43 +0530 Subject: [PATCH 07/22] link to new downloads --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 47edb505..2038c15b 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Useful for judging (and stopping) an image quickly, without waiting for it to fi You don't need to install or struggle with Python, Anaconda, Docker etc. The installer will take care of whatever is needed. # Installation -1. **Download** [for Windows](https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.3.5/stable-diffusion-ui-windows.zip) or [for Linux](https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.3.5/stable-diffusion-ui-linux.zip). +1. **Download** [for Windows](https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.4.13/stable-diffusion-ui-windows.zip) or [for Linux](https://github.com/cmdr2/stable-diffusion-ui/releases/download/v2.4.13/stable-diffusion-ui-linux.zip). 2. **Extract**: - For Windows: After unzipping the file, please move the `stable-diffusion-ui` folder to your `C:` (or any drive like D:, at the top root level), e.g. `C:\stable-diffusion-ui`. This will avoid a common problem with Windows (file path length limits). From 7097175c6f30b60ad135a8504c9f5a23c3780d56 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 11:07:50 +0530 Subject: [PATCH 08/22] CSS tweak for logo and version --- ui/index.html | 5 ++++- ui/media/css/main.css | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/index.html b/ui/index.html index 25a94a13..1b55499c 100644 --- a/ui/index.html +++ b/ui/index.html @@ -20,7 +20,10 @@
diff --git a/ui/media/css/main.css b/ui/media/css/main.css index 0cf83302..cc818800 100644 --- a/ui/media/css/main.css +++ b/ui/media/css/main.css @@ -131,6 +131,7 @@ code { } #logo small { font-size: 11pt; + margin-left: 7pt; } #editor { background: var(--background-color1); From 31c049ebfecabac4cd861e7bce004eb39727de86 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 11:09:01 +0530 Subject: [PATCH 09/22] Version css --- ui/media/css/main.css | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/media/css/main.css b/ui/media/css/main.css index cc818800..0cf83302 100644 --- a/ui/media/css/main.css +++ b/ui/media/css/main.css @@ -131,7 +131,6 @@ code { } #logo small { font-size: 11pt; - margin-left: 7pt; } #editor { background: var(--background-color1); From e8dd930a50dc8bbb094419213b51a216585807fd Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Tue, 22 Nov 2022 00:06:43 -0800 Subject: [PATCH 10/22] Add support for custom modifiers to d&d and clipboard Add support for custom modifiers to d&d and clipboard and remove now-redundant code in restoreTaskToUI. --- ui/media/js/dnd.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ui/media/js/dnd.js b/ui/media/js/dnd.js index 4c14333c..bb5dfe07 100644 --- a/ui/media/js/dnd.js +++ b/ui/media/js/dnd.js @@ -51,6 +51,13 @@ const TASK_MAPPING = { readUI: () => negativePromptField.value, parse: (val) => val }, + active_tags: { name: "Image Modifiers", + setUI: (active_tags) => { + refreshModifiersState(active_tags) + }, + readUI: () => activeTags.map(x => x.name), + parse: (val) => val + }, width: { name: 'Width', setUI: (width) => { const oldVal = widthField.value @@ -267,11 +274,6 @@ function restoreTaskToUI(task, fieldsToSkip) { // restore the original tag promptField.value = task.reqBody.original_prompt || task.reqBody.prompt - // Restore modifiers - if (task.reqBody.active_tags) { - refreshModifiersState(task.reqBody.active_tags) - } - // properly reset checkboxes if (!('use_face_correction' in task.reqBody)) { useFaceCorrectionField.checked = false From 93bbfac29a1b9d8beb7fbc4570b9cf3495d9df50 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 16:38:39 +0530 Subject: [PATCH 11/22] Change the backend to a custom fork of SD, since basujindal's fork is no longer under development. This fork is intended to include the common models/tools used like RealESRGAN, GFPGAN, Codeformer etc, and is meant to be a community-developed project --- CHANGES.md | 1 + scripts/on_sd_start.bat | 10 +- scripts/on_sd_start.sh | 10 +- ui/index.html | 2 +- ui/sd_internal/ddim_callback.patch | 254 +++++------------------------ ui/sd_internal/env_yaml.patch | 13 -- 6 files changed, 54 insertions(+), 236 deletions(-) delete mode 100644 ui/sd_internal/env_yaml.patch diff --git a/CHANGES.md b/CHANGES.md index 2b5ae762..db274ede 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ - A `What's New?` tab in the UI ### Detailed changelog +* 2.4.14 - 22 Nov 2022 - Change the backend to a custom fork of Stable Diffusion * 2.4.13 - 21 Nov 2022 - Change the modifier weight via mouse wheel, drag to reorder selected modifiers, and some more modifier-related fixes. Thanks @patriceac * 2.4.12 - 21 Nov 2022 - Another fix for improving how long images take to generate. Reduces the time taken for an enqueued task to start processing. * 2.4.11 - 21 Nov 2022 - Installer improvements: avoid crashing if the username contains a space or special characters, allow moving/renaming the folder after installation on Windows, whitespace fix on git apply diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index f1b459cb..96905778 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -33,18 +33,19 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @cd stable-diffusion + @call git remote set-url origin https://github.com/easydiffusion/diffusion-kit.git + @call git reset --hard @call git pull - @call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c + @call git -c advice.detachedHead=false checkout 675fdf5c5694b3590f86583112f70794fa17052f @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch - @call git apply --whitespace=nowarn ..\ui\sd_internal\env_yaml.patch @cd .. ) else ( @echo. & echo "Downloading Stable Diffusion.." & echo. - @call git clone https://github.com/basujindal/stable-diffusion.git && ( + @call git clone https://github.com/easydiffusion/diffusion-kit.git stable-diffusion && ( @echo sd_git_cloned >> scripts\install_status.txt ) || ( @echo "Error downloading Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" @@ -53,10 +54,9 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" ) @cd stable-diffusion - @call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c + @call git -c advice.detachedHead=false checkout 675fdf5c5694b3590f86583112f70794fa17052f @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch - @call git apply --whitespace=nowarn ..\ui\sd_internal\env_yaml.patch @cd .. ) diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 7745855a..4a7fb46e 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -26,28 +26,28 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta cd stable-diffusion + git remote set-url origin https://github.com/easydiffusion/diffusion-kit.git + git reset --hard git pull - git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c + git -c advice.detachedHead=false checkout 675fdf5c5694b3590f86583112f70794fa17052f git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" - git apply --whitespace=nowarn ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" cd .. else printf "\n\nDownloading Stable Diffusion..\n\n" - if git clone https://github.com/basujindal/stable-diffusion.git ; then + if git clone https://github.com/easydiffusion/diffusion-kit.git stable-diffusion ; then echo sd_git_cloned >> scripts/install_status.txt else fail "git clone of basujindal/stable-diffusion.git failed" fi cd stable-diffusion - git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c + git -c advice.detachedHead=false checkout 675fdf5c5694b3590f86583112f70794fa17052f git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" - git apply --whitespace=nowarn ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" cd .. fi diff --git a/ui/index.html b/ui/index.html index 1b55499c..3e85b254 100644 --- a/ui/index.html +++ b/ui/index.html @@ -22,7 +22,7 @@
diff --git a/ui/sd_internal/ddim_callback.patch b/ui/sd_internal/ddim_callback.patch index 36335abe..e4dd69e0 100644 --- a/ui/sd_internal/ddim_callback.patch +++ b/ui/sd_internal/ddim_callback.patch @@ -1,72 +1,13 @@ diff --git a/optimizedSD/ddpm.py b/optimizedSD/ddpm.py -index b967b55..35ef520 100644 +index 79058bc..a473411 100644 --- a/optimizedSD/ddpm.py +++ b/optimizedSD/ddpm.py -@@ -22,7 +22,7 @@ from ldm.util import exists, default, instantiate_from_config - from ldm.modules.diffusionmodules.util import make_beta_schedule - from ldm.modules.diffusionmodules.util import make_ddim_sampling_parameters, make_ddim_timesteps, noise_like - from ldm.modules.diffusionmodules.util import make_beta_schedule, extract_into_tensor, noise_like --from samplers import CompVisDenoiser, get_ancestral_step, to_d, append_dims,linear_multistep_coeff -+from .samplers import CompVisDenoiser, get_ancestral_step, to_d, append_dims,linear_multistep_coeff +@@ -564,12 +564,12 @@ class UNet(DDPM): + unconditional_guidance_scale=unconditional_guidance_scale, + callback=callback, img_callback=img_callback) - def disabled_train(self): - """Overwrite model.train with this function to make sure train/eval mode -@@ -506,6 +506,8 @@ class UNet(DDPM): - - x_latent = noise if x0 is None else x0 - # sampling -+ if sampler in ('ddim', 'dpm2', 'heun', 'dpm2_a', 'lms') and not hasattr(self, 'ddim_timesteps'): -+ self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False) - - if sampler == "plms": - self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False) -@@ -528,39 +530,46 @@ class UNet(DDPM): - elif sampler == "ddim": - samples = self.ddim_sampling(x_latent, conditioning, S, unconditional_guidance_scale=unconditional_guidance_scale, - unconditional_conditioning=unconditional_conditioning, -- mask = mask,init_latent=x_T,use_original_steps=False) -+ mask = mask,init_latent=x_T,use_original_steps=False, -+ callback=callback, img_callback=img_callback) - - elif sampler == "euler": - self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False) - samples = self.euler_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning, -- unconditional_guidance_scale=unconditional_guidance_scale) -+ unconditional_guidance_scale=unconditional_guidance_scale, -+ img_callback=img_callback) - elif sampler == "euler_a": - self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False) - samples = self.euler_ancestral_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning, -- unconditional_guidance_scale=unconditional_guidance_scale) -+ unconditional_guidance_scale=unconditional_guidance_scale, -+ img_callback=img_callback) - - elif sampler == "dpm2": - samples = self.dpm_2_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning, -- unconditional_guidance_scale=unconditional_guidance_scale) -+ unconditional_guidance_scale=unconditional_guidance_scale, -+ img_callback=img_callback) - elif sampler == "heun": - samples = self.heun_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning, -- unconditional_guidance_scale=unconditional_guidance_scale) -+ unconditional_guidance_scale=unconditional_guidance_scale, -+ img_callback=img_callback) - - elif sampler == "dpm2_a": - samples = self.dpm_2_ancestral_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning, -- unconditional_guidance_scale=unconditional_guidance_scale) -+ unconditional_guidance_scale=unconditional_guidance_scale, -+ img_callback=img_callback) - - - elif sampler == "lms": - samples = self.lms_sampling(self.alphas_cumprod,x_latent, S, conditioning, unconditional_conditioning=unconditional_conditioning, -- unconditional_guidance_scale=unconditional_guidance_scale) -+ unconditional_guidance_scale=unconditional_guidance_scale, -+ img_callback=img_callback) -+ + yield from samples - ++ if(self.turbo): self.model1.to("cpu") self.model2.to("cpu") @@ -76,7 +17,7 @@ index b967b55..35ef520 100644 @torch.no_grad() def plms_sampling(self, cond,b, img, ddim_use_original_steps=False, -@@ -599,10 +608,10 @@ class UNet(DDPM): +@@ -608,10 +608,10 @@ class UNet(DDPM): old_eps.append(e_t) if len(old_eps) >= 4: old_eps.pop(0) @@ -90,23 +31,15 @@ index b967b55..35ef520 100644 @torch.no_grad() def p_sample_plms(self, x, c, t, index, repeat_noise=False, use_original_steps=False, quantize_denoised=False, -@@ -706,7 +715,8 @@ class UNet(DDPM): - - @torch.no_grad() - def ddim_sampling(self, x_latent, cond, t_start, unconditional_guidance_scale=1.0, unconditional_conditioning=None, -- mask = None,init_latent=None,use_original_steps=False): -+ mask = None,init_latent=None,use_original_steps=False, -+ callback=None, img_callback=None): - - timesteps = self.ddim_timesteps - timesteps = timesteps[:t_start] -@@ -730,10 +740,13 @@ class UNet(DDPM): +@@ -740,13 +740,13 @@ class UNet(DDPM): unconditional_guidance_scale=unconditional_guidance_scale, unconditional_conditioning=unconditional_conditioning) - + +- if callback: callback(i) +- if img_callback: img_callback(x_dec, i) + if callback: yield from callback(i) + if img_callback: yield from img_callback(x_dec, i) -+ + if mask is not None: - return x0 * mask + (1. - mask) * x_dec + x_dec = x0 * mask + (1. - mask) * x_dec @@ -116,217 +49,114 @@ index b967b55..35ef520 100644 @torch.no_grad() -@@ -779,13 +792,16 @@ class UNet(DDPM): +@@ -820,12 +820,12 @@ class UNet(DDPM): - @torch.no_grad() -- def euler_sampling(self, ac, x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None,callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1.): -+ def euler_sampling(self, ac, x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None,callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1., -+ img_callback=None): - """Implements Algorithm 2 (Euler steps) from Karras et al. (2022).""" - extra_args = {} if extra_args is None else extra_args - cvd = CompVisDenoiser(ac) - sigmas = cvd.get_sigmas(S) - x = x*sigmas[0] - -+ print(f"Running Euler Sampling with {len(sigmas) - 1} timesteps") -+ - s_in = x.new_ones([x.shape[0]]).half() - for i in trange(len(sigmas) - 1, disable=disable): - gamma = min(s_churn / (len(sigmas) - 1), 2 ** 0.5 - 1) if s_tmin <= sigmas[i] <= s_tmax else 0. -@@ -807,13 +823,18 @@ class UNet(DDPM): d = to_d(x, sigma_hat, denoised) - if callback is not None: - callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigma_hat, 'denoised': denoised}) -+ +- if callback: callback(i) +- if img_callback: img_callback(x, i) ++ if callback: yield from callback(i) + if img_callback: yield from img_callback(x, i) -+ dt = sigmas[i + 1] - sigma_hat # Euler method x = x + d * dt - return x -+ + yield from img_callback(x, len(sigmas)-1) @torch.no_grad() -- def euler_ancestral_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None, callback=None, disable=None): -+ def euler_ancestral_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None, callback=None, disable=None, -+ img_callback=None): - """Ancestral sampling with Euler method steps.""" - extra_args = {} if extra_args is None else extra_args + def euler_ancestral_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None, callback=None, disable=None, img_callback=None): +@@ -852,14 +852,14 @@ class UNet(DDPM): + denoised = e_t_uncond + unconditional_guidance_scale * (e_t - e_t_uncond) -@@ -822,6 +843,8 @@ class UNet(DDPM): - sigmas = cvd.get_sigmas(S) - x = x*sigmas[0] - -+ print(f"Running Euler Ancestral Sampling with {len(sigmas) - 1} timesteps") -+ - s_in = x.new_ones([x.shape[0]]).half() - for i in trange(len(sigmas) - 1, disable=disable): - -@@ -837,17 +860,22 @@ class UNet(DDPM): sigma_down, sigma_up = get_ancestral_step(sigmas[i], sigmas[i + 1]) - if callback is not None: - callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigmas[i], 'denoised': denoised}) -+ +- if callback: callback(i) +- if img_callback: img_callback(x, i) ++ if callback: yield from callback(i) + if img_callback: yield from img_callback(x, i) -+ d = to_d(x, sigmas[i], denoised) # Euler method dt = sigma_down - sigmas[i] x = x + d * dt x = x + torch.randn_like(x) * sigma_up - return x -+ + yield from img_callback(x, len(sigmas)-1) - @torch.no_grad() -- def heun_sampling(self, ac, x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1.): -+ def heun_sampling(self, ac, x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1., -+ img_callback=None): - """Implements Algorithm 2 (Heun steps) from Karras et al. (2022).""" - extra_args = {} if extra_args is None else extra_args +@@ -892,8 +892,8 @@ class UNet(DDPM): + denoised = e_t_uncond + unconditional_guidance_scale * (e_t - e_t_uncond) -@@ -855,6 +883,8 @@ class UNet(DDPM): - sigmas = cvd.get_sigmas(S) - x = x*sigmas[0] - -+ print(f"Running Heun Sampling with {len(sigmas) - 1} timesteps") -+ - - s_in = x.new_ones([x.shape[0]]).half() - for i in trange(len(sigmas) - 1, disable=disable): -@@ -876,6 +906,9 @@ class UNet(DDPM): d = to_d(x, sigma_hat, denoised) - if callback is not None: - callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigma_hat, 'denoised': denoised}) -+ +- if callback: callback(i) +- if img_callback: img_callback(x, i) ++ if callback: yield from callback(i) + if img_callback: yield from img_callback(x, i) -+ dt = sigmas[i + 1] - sigma_hat if sigmas[i + 1] == 0: # Euler method -@@ -895,11 +928,13 @@ class UNet(DDPM): +@@ -913,7 +913,7 @@ class UNet(DDPM): d_2 = to_d(x_2, sigmas[i + 1], denoised_2) d_prime = (d + d_2) / 2 x = x + d_prime * dt - return x -+ + yield from img_callback(x, len(sigmas)-1) @torch.no_grad() -- def dpm_2_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None, callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1.): -+ def dpm_2_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1,extra_args=None, callback=None, disable=None, s_churn=0., s_tmin=0., s_tmax=float('inf'), s_noise=1., -+ img_callback=None): - """A sampler inspired by DPM-Solver-2 and Algorithm 2 from Karras et al. (2022).""" - extra_args = {} if extra_args is None else extra_args - -@@ -907,6 +942,8 @@ class UNet(DDPM): - sigmas = cvd.get_sigmas(S) - x = x*sigmas[0] - -+ print(f"Running DPM2 Sampling with {len(sigmas) - 1} timesteps") -+ - s_in = x.new_ones([x.shape[0]]).half() - for i in trange(len(sigmas) - 1, disable=disable): - gamma = min(s_churn / (len(sigmas) - 1), 2 ** 0.5 - 1) if s_tmin <= sigmas[i] <= s_tmax else 0. -@@ -924,7 +961,7 @@ class UNet(DDPM): +@@ -944,8 +944,8 @@ class UNet(DDPM): e_t_uncond, e_t = (x_in + eps * c_out).chunk(2) denoised = e_t_uncond + unconditional_guidance_scale * (e_t - e_t_uncond) -- +- if callback: callback(i) +- if img_callback: img_callback(x, i) ++ if callback: yield from callback(i) + if img_callback: yield from img_callback(x, i) d = to_d(x, sigma_hat, denoised) # Midpoint method, where the midpoint is chosen according to a rho=3 Karras schedule -@@ -945,11 +982,13 @@ class UNet(DDPM): +@@ -966,7 +966,7 @@ class UNet(DDPM): d_2 = to_d(x_2, sigma_mid, denoised_2) x = x + d_2 * dt_2 - return x -+ + yield from img_callback(x, len(sigmas)-1) @torch.no_grad() -- def dpm_2_ancestral_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None): -+ def dpm_2_ancestral_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None, -+ img_callback=None): - """Ancestral sampling with DPM-Solver inspired second-order steps.""" - extra_args = {} if extra_args is None else extra_args +@@ -994,8 +994,8 @@ class UNet(DDPM): -@@ -957,6 +996,8 @@ class UNet(DDPM): - sigmas = cvd.get_sigmas(S) - x = x*sigmas[0] -+ print(f"Running DPM2 Ancestral Sampling with {len(sigmas) - 1} timesteps") -+ - s_in = x.new_ones([x.shape[0]]).half() - for i in trange(len(sigmas) - 1, disable=disable): - -@@ -973,6 +1014,9 @@ class UNet(DDPM): sigma_down, sigma_up = get_ancestral_step(sigmas[i], sigmas[i + 1]) - if callback is not None: - callback({'x': x, 'i': i, 'sigma': sigmas[i], 'sigma_hat': sigmas[i], 'denoised': denoised}) -+ +- if callback: callback(i) +- if img_callback: img_callback(x, i) ++ if callback: yield from callback(i) + if img_callback: yield from img_callback(x, i) -+ d = to_d(x, sigmas[i], denoised) # Midpoint method, where the midpoint is chosen according to a rho=3 Karras schedule sigma_mid = ((sigmas[i] ** (1 / 3) + sigma_down ** (1 / 3)) / 2) ** 3 -@@ -993,11 +1037,13 @@ class UNet(DDPM): +@@ -1016,7 +1016,7 @@ class UNet(DDPM): d_2 = to_d(x_2, sigma_mid, denoised_2) x = x + d_2 * dt_2 x = x + torch.randn_like(x) * sigma_up - return x -+ + yield from img_callback(x, len(sigmas)-1) @torch.no_grad() -- def lms_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None, order=4): -+ def lms_sampling(self,ac,x, S, cond, unconditional_conditioning = None, unconditional_guidance_scale = 1, extra_args=None, callback=None, disable=None, order=4, -+ img_callback=None): - extra_args = {} if extra_args is None else extra_args - s_in = x.new_ones([x.shape[0]]) - -@@ -1005,6 +1051,8 @@ class UNet(DDPM): - sigmas = cvd.get_sigmas(S) - x = x*sigmas[0] - -+ print(f"Running LMS Sampling with {len(sigmas) - 1} timesteps") -+ - ds = [] - for i in trange(len(sigmas) - 1, disable=disable): - -@@ -1017,6 +1065,7 @@ class UNet(DDPM): +@@ -1042,8 +1042,8 @@ class UNet(DDPM): e_t_uncond, e_t = (x_in + eps * c_out).chunk(2) denoised = e_t_uncond + unconditional_guidance_scale * (e_t - e_t_uncond) +- if callback: callback(i) +- if img_callback: img_callback(x, i) ++ if callback: yield from callback(i) + if img_callback: yield from img_callback(x, i) d = to_d(x, sigmas[i], denoised) ds.append(d) -@@ -1027,4 +1076,5 @@ class UNet(DDPM): +@@ -1054,4 +1054,4 @@ class UNet(DDPM): cur_order = min(i + 1, order) coeffs = [linear_multistep_coeff(cur_order, sigmas.cpu(), i, j) for j in range(cur_order)] x = x + sum(coeff * d for coeff, d in zip(coeffs, reversed(ds))) - return x -+ + yield from img_callback(x, len(sigmas)-1) -diff --git a/optimizedSD/openaimodelSplit.py b/optimizedSD/openaimodelSplit.py -index abc3098..7a32ffe 100644 ---- a/optimizedSD/openaimodelSplit.py -+++ b/optimizedSD/openaimodelSplit.py -@@ -13,7 +13,7 @@ from ldm.modules.diffusionmodules.util import ( - normalization, - timestep_embedding, - ) --from splitAttention import SpatialTransformer -+from .splitAttention import SpatialTransformer - - - class AttentionPool2d(nn.Module): diff --git a/ui/sd_internal/env_yaml.patch b/ui/sd_internal/env_yaml.patch deleted file mode 100644 index cc140ef1..00000000 --- a/ui/sd_internal/env_yaml.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/environment.yaml b/environment.yaml -index 7f25da8..306750f 100644 ---- a/environment.yaml -+++ b/environment.yaml -@@ -23,6 +23,8 @@ dependencies: - - torch-fidelity==0.3.0 - - transformers==4.19.2 - - torchmetrics==0.6.0 -+ - pywavelets==1.3.0 -+ - pandas==1.4.4 - - kornia==0.6 - - -e git+https://github.com/CompVis/taming-transformers.git@master#egg=taming-transformers - - -e git+https://github.com/openai/CLIP.git@main#egg=clip From 72ee708917d0c5237d50250eec248483a81cb7ae Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 16:50:10 +0530 Subject: [PATCH 12/22] Remove the need to install realesrgan, gfpgan and certain specific package versions, since the new backend should install them directly --- scripts/on_sd_start.bat | 24 ------------------------ scripts/on_sd_start.sh | 18 ------------------ 2 files changed, 42 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 96905778..f1c9b785 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -88,12 +88,6 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @call conda activate .\env - @call conda install -c conda-forge -y --prefix env antlr4-python3-runtime=4.8 || ( - @echo. & echo "Error installing antlr4-python3-runtime for Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - for /f "tokens=*" %%a in ('python -c "import torch; import ldm; import transformers; import numpy; import antlr4; print(42)"') do if "%%a" NEQ "42" ( @echo. & echo "Dependency test failed! Error installing the packages necessary for Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. pause @@ -117,18 +111,6 @@ set PATH=C:\Windows\System32;%PATH% set PYTHONPATH=%cd%;%cd%\env\lib\site-packages - @call pip install -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN || ( - @echo. & echo "Error installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - - @call pip install basicsr==1.4.2 || ( - @echo. & echo "Error installing the basicsr package necessary for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - for /f "tokens=*" %%a in ('python -c "from gfpgan import GFPGANer; print(42)"') do if "%%a" NEQ "42" ( @echo. & echo "Dependency test failed! Error installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. pause @@ -150,12 +132,6 @@ set PATH=C:\Windows\System32;%PATH% set PYTHONPATH=%cd%;%cd%\env\lib\site-packages - @call pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan || ( - @echo. & echo "Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b - ) - for /f "tokens=*" %%a in ('python -c "from basicsr.archs.rrdbnet_arch import RRDBNet; from realesrgan import RealESRGANer; print(42)"') do if "%%a" NEQ "42" ( @echo. & echo "Dependency test failed! Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. pause diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 4a7fb46e..a2877cbc 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -74,12 +74,6 @@ else conda activate ./env || fail "conda activate failed" - if conda install -c conda-forge --prefix ./env -y antlr4-python3-runtime=4.8 ; then - echo "Installed. Testing.." - else - fail "Error installing antlr4-python3-runtime" - fi - out_test=`python -c "import torch; import ldm; import transformers; import numpy; import antlr4; print(42)"` if [ "$out_test" != "42" ]; then fail "Dependency test failed" @@ -96,12 +90,6 @@ else export PYTHONNOUSERSITE=1 export PYTHONPATH="$(pwd):$(pwd)/env/lib/site-packages" - if pip install -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN ; then - echo "Installed. Testing.." - else - fail "Error installing the packages necessary for GFPGAN (Face Correction)." - fi - out_test=`python -c "from gfpgan import GFPGANer; print(42)"` if [ "$out_test" != "42" ]; then echo "EE The dependency check has failed. This usually means that some system libraries are missing." @@ -121,12 +109,6 @@ else export PYTHONNOUSERSITE=1 export PYTHONPATH="$(pwd):$(pwd)/env/lib/site-packages" - if pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan ; then - echo "Installed. Testing.." - else - fail "Error installing the packages necessary for ESRGAN" - fi - out_test=`python -c "from basicsr.archs.rrdbnet_arch import RRDBNet; from realesrgan import RealESRGANer; print(42)"` if [ "$out_test" != "42" ]; then fail "ESRGAN dependency test failed" From d429505b71d4829f6f6b5bbbce5aa1b9b6fdee2d Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 17:14:20 +0530 Subject: [PATCH 13/22] Update version of diffusion-kit --- scripts/on_sd_start.bat | 4 ++-- scripts/on_sd_start.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index f1c9b785..978225ce 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -37,7 +37,7 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @call git reset --hard @call git pull - @call git -c advice.detachedHead=false checkout 675fdf5c5694b3590f86583112f70794fa17052f + @call git -c advice.detachedHead=false checkout 8b337661cbfc13cded9f47c828a277d97ae50505 @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch @@ -54,7 +54,7 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" ) @cd stable-diffusion - @call git -c advice.detachedHead=false checkout 675fdf5c5694b3590f86583112f70794fa17052f + @call git -c advice.detachedHead=false checkout 8b337661cbfc13cded9f47c828a277d97ae50505 @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index a2877cbc..2036affa 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -30,7 +30,7 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta git reset --hard git pull - git -c advice.detachedHead=false checkout 675fdf5c5694b3590f86583112f70794fa17052f + git -c advice.detachedHead=false checkout 8b337661cbfc13cded9f47c828a277d97ae50505 git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" @@ -45,7 +45,7 @@ else fi cd stable-diffusion - git -c advice.detachedHead=false checkout 675fdf5c5694b3590f86583112f70794fa17052f + git -c advice.detachedHead=false checkout 8b337661cbfc13cded9f47c828a277d97ae50505 git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" From d9b9f80a9363bd9c3cc9d0b94b843098812053a6 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 17:39:51 +0530 Subject: [PATCH 14/22] diffusion-kit upgrade --- scripts/on_sd_start.bat | 4 ++-- scripts/on_sd_start.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 978225ce..799ea9bd 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -37,7 +37,7 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @call git reset --hard @call git pull - @call git -c advice.detachedHead=false checkout 8b337661cbfc13cded9f47c828a277d97ae50505 + @call git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch @@ -54,7 +54,7 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" ) @cd stable-diffusion - @call git -c advice.detachedHead=false checkout 8b337661cbfc13cded9f47c828a277d97ae50505 + @call git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 2036affa..9e55f5d8 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -30,7 +30,7 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta git reset --hard git pull - git -c advice.detachedHead=false checkout 8b337661cbfc13cded9f47c828a277d97ae50505 + git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" @@ -45,7 +45,7 @@ else fi cd stable-diffusion - git -c advice.detachedHead=false checkout 8b337661cbfc13cded9f47c828a277d97ae50505 + git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" From 3169485f335341b9e5fb11416b2c7a5f79c315e6 Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Tue, 22 Nov 2022 11:09:47 -0500 Subject: [PATCH 15/22] Fixing file drag and drop. --- ui/media/js/dnd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/media/js/dnd.js b/ui/media/js/dnd.js index bb5dfe07..f344863b 100644 --- a/ui/media/js/dnd.js +++ b/ui/media/js/dnd.js @@ -408,7 +408,7 @@ async function parseContent(text) { } async function readFile(file, i) { - console.log(`Event %o reading file[${i}]:${file.name}...`, e) + console.log(`Event %o reading file[${i}]:${file.name}...`) const fileContent = (await file.text()).trim() return await parseContent(fileContent) } From d425dac499c7386464b2806889dcbd316a7a3579 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 21:56:07 +0530 Subject: [PATCH 16/22] Merge pull request #529 from madrang/dragNdrop Fixing file drag and drop. --- ui/media/js/dnd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/media/js/dnd.js b/ui/media/js/dnd.js index 4c14333c..62144a9b 100644 --- a/ui/media/js/dnd.js +++ b/ui/media/js/dnd.js @@ -406,7 +406,7 @@ async function parseContent(text) { } async function readFile(file, i) { - console.log(`Event %o reading file[${i}]:${file.name}...`, e) + console.log(`Event %o reading file[${i}]:${file.name}...`) const fileContent = (await file.text()).trim() return await parseContent(fileContent) } From 5af84b8e90166811b01ec65d2e720d942cccaa9a Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 22:21:54 +0530 Subject: [PATCH 17/22] Fix whitespace during git apply --- scripts/on_sd_start.bat | 4 ++-- scripts/on_sd_start.sh | 4 ++-- ui/sd_internal/ddim_callback.patch | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 799ea9bd..cd6ae984 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -39,7 +39,7 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @call git pull @call git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a - @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch + @call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch @cd .. ) else ( @@ -56,7 +56,7 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @cd stable-diffusion @call git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a - @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch + @call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch @cd .. ) diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 9e55f5d8..514262ab 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -32,7 +32,7 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta git pull git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a - git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" cd .. else @@ -47,7 +47,7 @@ else cd stable-diffusion git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a - git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" cd .. fi diff --git a/ui/sd_internal/ddim_callback.patch b/ui/sd_internal/ddim_callback.patch index e4dd69e0..f40695c2 100644 --- a/ui/sd_internal/ddim_callback.patch +++ b/ui/sd_internal/ddim_callback.patch @@ -39,7 +39,7 @@ index 79058bc..a473411 100644 - if img_callback: img_callback(x_dec, i) + if callback: yield from callback(i) + if img_callback: yield from img_callback(x_dec, i) - + if mask is not None: - return x0 * mask + (1. - mask) * x_dec + x_dec = x0 * mask + (1. - mask) * x_dec @@ -111,7 +111,7 @@ index 79058bc..a473411 100644 - if img_callback: img_callback(x, i) + if callback: yield from callback(i) + if img_callback: yield from img_callback(x, i) - + d = to_d(x, sigma_hat, denoised) # Midpoint method, where the midpoint is chosen according to a rho=3 Karras schedule @@ -966,7 +966,7 @@ class UNet(DDPM): From ab4e3715243a3177b701c3b250b8f158cc833e44 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 22:25:36 +0530 Subject: [PATCH 18/22] Fix whitespace during git apply --- scripts/on_sd_start.bat | 8 ++++---- scripts/on_sd_start.sh | 8 ++++---- ui/sd_internal/ddim_callback.patch | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index f1b459cb..a0813ec1 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -37,8 +37,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @call git pull @call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch - @call git apply --whitespace=nowarn ..\ui\sd_internal\env_yaml.patch + @call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch + @call git apply --whitespace=fix ..\ui\sd_internal\env_yaml.patch @cd .. ) else ( @@ -55,8 +55,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @cd stable-diffusion @call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - @call git apply --whitespace=nowarn ..\ui\sd_internal\ddim_callback.patch - @call git apply --whitespace=nowarn ..\ui\sd_internal\env_yaml.patch + @call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch + @call git apply --whitespace=fix ..\ui\sd_internal\env_yaml.patch @cd .. ) diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 7745855a..a4f92428 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -30,8 +30,8 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta git pull git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" - git apply --whitespace=nowarn ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" + git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply --whitespace=fix ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" cd .. else @@ -46,8 +46,8 @@ else cd stable-diffusion git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - git apply --whitespace=nowarn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" - git apply --whitespace=nowarn ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" + git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply --whitespace=fix ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" cd .. fi diff --git a/ui/sd_internal/ddim_callback.patch b/ui/sd_internal/ddim_callback.patch index 36335abe..9d5bd9e7 100644 --- a/ui/sd_internal/ddim_callback.patch +++ b/ui/sd_internal/ddim_callback.patch @@ -17,7 +17,7 @@ index b967b55..35ef520 100644 # sampling + if sampler in ('ddim', 'dpm2', 'heun', 'dpm2_a', 'lms') and not hasattr(self, 'ddim_timesteps'): + self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False) - + if sampler == "plms": self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False) @@ -528,39 +530,46 @@ class UNet(DDPM): @@ -103,7 +103,7 @@ index b967b55..35ef520 100644 @@ -730,10 +740,13 @@ class UNet(DDPM): unconditional_guidance_scale=unconditional_guidance_scale, unconditional_conditioning=unconditional_conditioning) - + + if callback: yield from callback(i) + if img_callback: yield from img_callback(x_dec, i) + @@ -239,7 +239,7 @@ index b967b55..35ef520 100644 - + if img_callback: yield from img_callback(x, i) - + d = to_d(x, sigma_hat, denoised) # Midpoint method, where the midpoint is chosen according to a rho=3 Karras schedule @@ -945,11 +982,13 @@ class UNet(DDPM): From daaa65dc0ab16071c047b9ca9aa32a995486f451 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 23:20:24 +0530 Subject: [PATCH 19/22] Warn but don't fix whitespaces in a patch --- scripts/on_sd_start.bat | 4 ++-- scripts/on_sd_start.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index cd6ae984..6e4ffd36 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -39,7 +39,7 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @call git pull @call git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a - @call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch + @call git apply --whitespace=warn ..\ui\sd_internal\ddim_callback.patch @cd .. ) else ( @@ -56,7 +56,7 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @cd stable-diffusion @call git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a - @call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch + @call git apply --whitespace=warn ..\ui\sd_internal\ddim_callback.patch @cd .. ) diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 514262ab..ff6a04d4 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -32,7 +32,7 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta git pull git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a - git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply --whitespace=warn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" cd .. else @@ -47,7 +47,7 @@ else cd stable-diffusion git -c advice.detachedHead=false checkout 7f32368ed1030a6e710537047bacd908adea183a - git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply --whitespace=warn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" cd .. fi From 5a9c8e1d87050edbc948fdcfb29e7809bbd6a1ac Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 23:21:11 +0530 Subject: [PATCH 20/22] Warn but don't fix whitespaces in a patch --- scripts/on_sd_start.bat | 8 ++++---- scripts/on_sd_start.sh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index a0813ec1..b6d03c53 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -37,8 +37,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @call git pull @call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - @call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch - @call git apply --whitespace=fix ..\ui\sd_internal\env_yaml.patch + @call git apply --whitespace=warn ..\ui\sd_internal\ddim_callback.patch + @call git apply --whitespace=warn ..\ui\sd_internal\env_yaml.patch @cd .. ) else ( @@ -55,8 +55,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" @cd stable-diffusion @call git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - @call git apply --whitespace=fix ..\ui\sd_internal\ddim_callback.patch - @call git apply --whitespace=fix ..\ui\sd_internal\env_yaml.patch + @call git apply --whitespace=warn ..\ui\sd_internal\ddim_callback.patch + @call git apply --whitespace=warn ..\ui\sd_internal\env_yaml.patch @cd .. ) diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index a4f92428..c808d691 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -30,8 +30,8 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta git pull git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" - git apply --whitespace=fix ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" + git apply --whitespace=warn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply --whitespace=warn ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" cd .. else @@ -46,8 +46,8 @@ else cd stable-diffusion git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - git apply --whitespace=fix ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" - git apply --whitespace=fix ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" + git apply --whitespace=warn ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply --whitespace=warn ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" cd .. fi From 3b0ace3410e6c0ea7835f25b6eb3edab18ae9f85 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 23:27:46 +0530 Subject: [PATCH 21/22] Revert whitespace fix --- ui/sd_internal/ddim_callback.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/sd_internal/ddim_callback.patch b/ui/sd_internal/ddim_callback.patch index 9d5bd9e7..36335abe 100644 --- a/ui/sd_internal/ddim_callback.patch +++ b/ui/sd_internal/ddim_callback.patch @@ -17,7 +17,7 @@ index b967b55..35ef520 100644 # sampling + if sampler in ('ddim', 'dpm2', 'heun', 'dpm2_a', 'lms') and not hasattr(self, 'ddim_timesteps'): + self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False) - + if sampler == "plms": self.make_schedule(ddim_num_steps=S, ddim_eta=eta, verbose=False) @@ -528,39 +530,46 @@ class UNet(DDPM): @@ -103,7 +103,7 @@ index b967b55..35ef520 100644 @@ -730,10 +740,13 @@ class UNet(DDPM): unconditional_guidance_scale=unconditional_guidance_scale, unconditional_conditioning=unconditional_conditioning) - + + if callback: yield from callback(i) + if img_callback: yield from img_callback(x_dec, i) + @@ -239,7 +239,7 @@ index b967b55..35ef520 100644 - + if img_callback: yield from img_callback(x, i) - + d = to_d(x, sigma_hat, denoised) # Midpoint method, where the midpoint is chosen according to a rho=3 Karras schedule @@ -945,11 +982,13 @@ class UNet(DDPM): From 7cbf62cf12d9874d8d33dddc7b2dd9bebe26aa20 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 22 Nov 2022 23:30:03 +0530 Subject: [PATCH 22/22] Revert whitespace fix --- ui/sd_internal/ddim_callback.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/sd_internal/ddim_callback.patch b/ui/sd_internal/ddim_callback.patch index f40695c2..e4dd69e0 100644 --- a/ui/sd_internal/ddim_callback.patch +++ b/ui/sd_internal/ddim_callback.patch @@ -39,7 +39,7 @@ index 79058bc..a473411 100644 - if img_callback: img_callback(x_dec, i) + if callback: yield from callback(i) + if img_callback: yield from img_callback(x_dec, i) - + if mask is not None: - return x0 * mask + (1. - mask) * x_dec + x_dec = x0 * mask + (1. - mask) * x_dec @@ -111,7 +111,7 @@ index 79058bc..a473411 100644 - if img_callback: img_callback(x, i) + if callback: yield from callback(i) + if img_callback: yield from img_callback(x, i) - + d = to_d(x, sigma_hat, denoised) # Midpoint method, where the midpoint is chosen according to a rho=3 Karras schedule @@ -966,7 +966,7 @@ class UNet(DDPM):