From ce2a42ca131dd96783484b77f3a3fec2519aac25 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Thu, 25 May 2023 20:18:19 +0200 Subject: [PATCH 01/33] Update "How to install and run.txt" --- How to install and run.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/How to install and run.txt b/How to install and run.txt index e48d217c..705c34f4 100644 --- a/How to install and run.txt +++ b/How to install and run.txt @@ -5,10 +5,10 @@ If you haven't downloaded Stable Diffusion UI yet, please download from https:// After downloading, to install please follow these instructions: For Windows: -- Please double-click the "Start Stable Diffusion UI.cmd" file inside the "stable-diffusion-ui" folder. +- Please double-click the "Easy-Diffusion-Windows.exe" file and follow the instructions. For Linux: -- Please open a terminal, and go to the "stable-diffusion-ui" directory. Then run ./start.sh +- Please open a terminal, unzip the Easy-Diffusion-Linux.zip file and go to the "easy-diffusion" directory. Then run ./start.sh That file will automatically install everything. After that it will start the Stable Diffusion interface in a web browser. @@ -21,4 +21,4 @@ If you have any problems, please: 3. Or, file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues Thanks -cmdr2 (and contributors to the project) \ No newline at end of file +cmdr2 (and contributors to the project) From a2856b2b77d55d1e58048674914747c562d31768 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 8 Jun 2023 16:47:50 +0530 Subject: [PATCH 02/33] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6a629e57..7c2981b3 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Click the download button for your operating system: - Minimum 8 GB of system RAM. - Atleast 25 GB of space on the hard disk. + The installer will take care of whatever is needed. If you face any problems, you can join the friendly [Discord community](https://discord.com/invite/u9yhsFmEkB) and ask for assistance. ## On Windows: From 656acafed3ba40ce1fc1a57067cae911565e3eef Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 30 Jun 2023 09:52:10 +0530 Subject: [PATCH 03/33] Don't read config.yaml just yet in the main branch --- scripts/get_config.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/get_config.py b/scripts/get_config.py index 9cdfb2fe..a468d906 100644 --- a/scripts/get_config.py +++ b/scripts/get_config.py @@ -4,7 +4,7 @@ import sys # The config file is in the same directory as this script config_directory = os.path.dirname(__file__) -config_yaml = os.path.join(config_directory, "config.yaml") +# config_yaml = os.path.join(config_directory, "config.yaml") config_json = os.path.join(config_directory, "config.json") parser = argparse.ArgumentParser(description='Get values from config file') @@ -16,15 +16,16 @@ parser.add_argument('key', metavar='key', nargs='+', args = parser.parse_args() -if os.path.isfile(config_yaml): - import yaml - with open(config_yaml, 'r') as configfile: - try: - config = yaml.safe_load(configfile) - except Exception as e: - print(e, file=sys.stderr) - config = {} -elif os.path.isfile(config_json): +# if os.path.isfile(config_yaml): +# import yaml +# with open(config_yaml, 'r') as configfile: +# try: +# config = yaml.safe_load(configfile) +# except Exception as e: +# print(e, file=sys.stderr) +# config = {} +# el +if os.path.isfile(config_json): import json with open(config_json, 'r') as configfile: try: From cf87c34befa7ece1361b67142b8ebaea9d518bcc Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 30 Jun 2023 15:53:54 +0530 Subject: [PATCH 04/33] Allow main to switch back from yaml to json config files --- ui/easydiffusion/app.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ui/easydiffusion/app.py b/ui/easydiffusion/app.py index 38e3392c..7e9e7890 100644 --- a/ui/easydiffusion/app.py +++ b/ui/easydiffusion/app.py @@ -100,7 +100,22 @@ def init(): def getConfig(default_val=APP_CONFIG_DEFAULTS): try: config_json_path = os.path.join(CONFIG_DIR, "config.json") - if not os.path.exists(config_json_path): + + # compatibility with upcoming yaml changes, switching from beta to main + config_yaml_path = os.path.join(CONFIG_DIR, "config.yaml") + if os.path.exists(config_yaml_path): + try: + import yaml + + with open(config_yaml_path, "r", encoding="utf-8") as f: + config = yaml.safe_load(f) + + setConfig(config) # save to config.json + os.remove(config_yaml_path) # delete the yaml file + except: + log.warn(traceback.format_exc()) + config = default_val + elif not os.path.exists(config_json_path): config = default_val else: with open(config_json_path, "r", encoding="utf-8") as f: From 3120b593c67071a56d7b1c71f06656ff83fc3f03 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 30 Jun 2023 16:30:29 +0530 Subject: [PATCH 05/33] Handle the legacy yaml config path --- ui/easydiffusion/app.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/easydiffusion/app.py b/ui/easydiffusion/app.py index 7e9e7890..3beabbb7 100644 --- a/ui/easydiffusion/app.py +++ b/ui/easydiffusion/app.py @@ -102,7 +102,13 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS): config_json_path = os.path.join(CONFIG_DIR, "config.json") # compatibility with upcoming yaml changes, switching from beta to main - config_yaml_path = os.path.join(CONFIG_DIR, "config.yaml") + config_yaml_path = os.path.join(CONFIG_DIR, "..", "config.yaml") + + # migrate the old config yaml location + config_legacy_yaml = os.path.join(CONFIG_DIR, "config.yaml") + if os.path.isfile(config_legacy_yaml): + shutil.move(config_legacy_yaml, config_yaml_path) + if os.path.exists(config_yaml_path): try: import yaml From 788404f66ac59ca547d6cf498362687c6467e62b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 12 Jul 2023 10:29:19 +0530 Subject: [PATCH 06/33] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7c2981b3..a0c7be1a 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ Does not require technical knowledge, does not require pre-installed software. 1 Click the download button for your operating system:

- - - + + +

**Hardware requirements:** From 710208f3768077aabccbeaaee9d93356a91573fa Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 19 Jul 2023 23:33:57 +0530 Subject: [PATCH 07/33] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index a0c7be1a..3a38f15d 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,15 @@ We could really use help on these aspects (click to view tasks that need your he If you have any code contributions in mind, please feel free to say Hi to us on the [discord server](https://discord.com/invite/u9yhsFmEkB). We use the Discord server for development-related discussions, and for helping users. +# Credits +* Stable Diffusion: https://github.com/Stability-AI/stablediffusion +* CodeFormer: https://github.com/sczhou/CodeFormer (license: https://github.com/sczhou/CodeFormer/blob/master/LICENSE) +* GFPGAN: https://github.com/TencentARC/GFPGAN +* RealESRGAN: https://github.com/xinntao/Real-ESRGAN +* k-diffusion: https://github.com/crowsonkb/k-diffusion +* Code contributors and artists on the cmdr2 UI: https://github.com/cmdr2/stable-diffusion-ui and Discord (https://discord.com/invite/u9yhsFmEkB) +* Lots of contributors on the internet + # Disclaimer The authors of this project are not responsible for any content generated using this interface. From 56f92ccab01fa1643b37e43c0f6dadf6b478b9d1 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 1 Aug 2023 21:24:22 +0530 Subject: [PATCH 08/33] Don't restrict TRT to batch size 1 --- ui/media/js/main.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 206d1338..0db31abe 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -1355,15 +1355,15 @@ function getCurrentUserRequest() { let numOutputsParallel = parseInt(numOutputsParallelField.value) const seed = randomSeedField.checked ? Math.floor(Math.random() * (2 ** 32 - 1)) : parseInt(seedField.value) - if ( - testDiffusers.checked && - document.getElementById("toggle-tensorrt-install").innerHTML == "Uninstall" && - document.querySelector("#convert_to_tensorrt").checked - ) { - // TRT enabled + // if ( + // testDiffusers.checked && + // document.getElementById("toggle-tensorrt-install").innerHTML == "Uninstall" && + // document.querySelector("#convert_to_tensorrt").checked + // ) { + // // TRT enabled - numOutputsParallel = 1 // force 1 parallel - } + // numOutputsParallel = 1 // force 1 parallel + // } const newTask = { batchesDone: 0, @@ -2394,8 +2394,8 @@ function packagesUpdate(event) { seedField.disabled = false stableDiffusionModelField.value = "sd-v1-4" - numOutputsParallelField.classList.add("displayNone") - document.querySelector("#num_outputs_parallel_label").classList.add("displayNone") + // numOutputsParallelField.classList.add("displayNone") + // document.querySelector("#num_outputs_parallel_label").classList.add("displayNone") trtSettingsForced = true } From fa58996f37b336a0cb7be9a64c5716422645763e Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 1 Aug 2023 23:53:01 +0530 Subject: [PATCH 09/33] sdkit 1.0.157 - tensorRT build configuration from the UI; clamp images to 8 instead of 64 pixels --- scripts/check_modules.py | 2 +- ui/easydiffusion/types.py | 3 +++ ui/media/js/main.js | 17 +++++++++++++++++ ui/media/js/parameters.js | 21 ++++++++++++++++----- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/scripts/check_modules.py b/scripts/check_modules.py index 51ecf3e7..4513e87b 100644 --- a/scripts/check_modules.py +++ b/scripts/check_modules.py @@ -18,7 +18,7 @@ os_name = platform.system() modules_to_check = { "torch": ("1.11.0", "1.13.1", "2.0.0"), "torchvision": ("0.12.0", "0.14.1", "0.15.1"), - "sdkit": "1.0.156", + "sdkit": "1.0.157", "stable-diffusion-sdkit": "2.1.4", "rich": "12.6.0", "uvicorn": "0.19.0", diff --git a/ui/easydiffusion/types.py b/ui/easydiffusion/types.py index 181a9505..bf5772f0 100644 --- a/ui/easydiffusion/types.py +++ b/ui/easydiffusion/types.py @@ -226,6 +226,9 @@ def convert_legacy_render_req_to_new(old_req: dict): model_params["stable-diffusion"] = { "clip_skip": bool(old_req.get("clip_skip", False)), "convert_to_tensorrt": bool(old_req.get("convert_to_tensorrt", False)), + "trt_build_config": old_req.get( + "trt_build_config", {"batch_size_range": (1, 2), "dimensions_range": [(768, 1024)]} + ), } # move the filter params diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 0db31abe..21e55923 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -1452,6 +1452,22 @@ function getCurrentUserRequest() { if (testDiffusers.checked && document.getElementById("toggle-tensorrt-install").innerHTML == "Uninstall") { // TRT is installed newTask.reqBody.convert_to_tensorrt = document.querySelector("#convert_to_tensorrt").checked + let trtBuildConfig = { + batch_size_range: [ + parseInt(document.querySelector("#trt-build-min-batch").value), + parseInt(document.querySelector("#trt-build-max-batch").value), + ], + dimensions_range: [], + } + + let sizes = [512, 768, 1024, 1280, 1536] + sizes.forEach((i) => { + let el = document.querySelector("#trt-build-res-" + i) + if (el.checked) { + trtBuildConfig["dimensions_range"].push([i, i + 256]) + } + }) + newTask.reqBody.trt_build_config = trtBuildConfig } if (controlnetModelField.value !== "" && IMAGE_REGEX.test(controlImagePreview.src)) { newTask.reqBody.use_controlnet_model = controlnetModelField.value @@ -2383,6 +2399,7 @@ function packagesUpdate(event) { if (document.getElementById("toggle-tensorrt-install").innerHTML == "Uninstall") { document.querySelector("#enable_trt_config").classList.remove("displayNone") + document.querySelector("#trt-build-config").classList.remove("displayNone") if (!trtSettingsForced) { // settings for demo diff --git a/ui/media/js/parameters.js b/ui/media/js/parameters.js index 19892c94..8b66c461 100644 --- a/ui/media/js/parameters.js +++ b/ui/media/js/parameters.js @@ -248,7 +248,18 @@ var PARAMETERS = [ label: "NVIDIA TensorRT", note: `Faster image generation by converting your Stable Diffusion models to the NVIDIA TensorRT format. You can choose the models to convert. Download size: approximately 2 GB.

- Early access version: support for LoRA is still under development.`, + Early access version: support for LoRA is still under development. +
+

Build Config:

+ Min batch size:
+ Max batch size:

+ Build for resolutions:
+ 512x512 to 768x768
+ 768x768 to 1024x1024
+ 1024x1024 to 1280x1280
+ 1280x1280 to 1536x1536
+ 1536x1536 to 1792x1792
+
`, icon: "fa-angles-up", render: () => '', table: installExtrasTable, @@ -453,8 +464,8 @@ async function getAppConfig() { document.querySelectorAll("#sampler_name option.diffusers-only").forEach((option) => { option.style.display = "none" }) - customWidthField.step=64 - customHeightField.step=64 + customWidthField.step = 64 + customHeightField.step = 64 } else { document.querySelector("#lora_model_container").style.display = "" document.querySelector("#tiling_container").style.display = "" @@ -465,8 +476,8 @@ async function getAppConfig() { document.querySelector("#clip_skip_config").classList.remove("displayNone") document.querySelector("#embeddings-button").classList.remove("displayNone") document.querySelector("#negative-embeddings-button").classList.remove("displayNone") - customWidthField.step=8 - customHeightField.step=8 + customWidthField.step = 8 + customHeightField.step = 8 } console.log("get config status response", config) From 38ab5b090f16bad5d08c8769e72056019954d77a Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 00:08:43 +0530 Subject: [PATCH 10/33] TRT ui changes --- scripts/check_modules.py | 2 +- ui/media/js/main.js | 4 ++-- ui/media/js/parameters.js | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/check_modules.py b/scripts/check_modules.py index 4513e87b..b4da8c58 100644 --- a/scripts/check_modules.py +++ b/scripts/check_modules.py @@ -18,7 +18,7 @@ os_name = platform.system() modules_to_check = { "torch": ("1.11.0", "1.13.1", "2.0.0"), "torchvision": ("0.12.0", "0.14.1", "0.15.1"), - "sdkit": "1.0.157", + "sdkit": "1.0.158", "stable-diffusion-sdkit": "2.1.4", "rich": "12.6.0", "uvicorn": "0.19.0", diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 21e55923..3ec2723c 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -1454,8 +1454,8 @@ function getCurrentUserRequest() { newTask.reqBody.convert_to_tensorrt = document.querySelector("#convert_to_tensorrt").checked let trtBuildConfig = { batch_size_range: [ - parseInt(document.querySelector("#trt-build-min-batch").value), - parseInt(document.querySelector("#trt-build-max-batch").value), + parseInt(document.querySelector("#trt-build-batch").value), + parseInt(document.querySelector("#trt-build-batch").value), ], dimensions_range: [], } diff --git a/ui/media/js/parameters.js b/ui/media/js/parameters.js index 8b66c461..96bcad87 100644 --- a/ui/media/js/parameters.js +++ b/ui/media/js/parameters.js @@ -251,8 +251,7 @@ var PARAMETERS = [ Early access version: support for LoRA is still under development.

Build Config:

- Min batch size:
- Max batch size:

+ Batch size:

Build for resolutions:
512x512 to 768x768
768x768 to 1024x1024
From 53b5ce6e2cf94ea3b24a59bf0a6745bd136991f5 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 00:10:19 +0530 Subject: [PATCH 11/33] typo --- ui/easydiffusion/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/easydiffusion/types.py b/ui/easydiffusion/types.py index bf5772f0..fe936ca2 100644 --- a/ui/easydiffusion/types.py +++ b/ui/easydiffusion/types.py @@ -227,7 +227,7 @@ def convert_legacy_render_req_to_new(old_req: dict): "clip_skip": bool(old_req.get("clip_skip", False)), "convert_to_tensorrt": bool(old_req.get("convert_to_tensorrt", False)), "trt_build_config": old_req.get( - "trt_build_config", {"batch_size_range": (1, 2), "dimensions_range": [(768, 1024)]} + "trt_build_config", {"batch_size_range": (1, 1), "dimensions_range": [(768, 1024)]} ), } From 7d496f4ad06b350840f6f40811a302d5e79ec133 Mon Sep 17 00:00:00 2001 From: Olivia Godone-Maresca <8977984+ogmaresca@users.noreply.github.com> Date: Wed, 2 Aug 2023 00:43:21 -0400 Subject: [PATCH 12/33] Add ControlNet model and filter to metadata (#1454) --- ui/easydiffusion/utils/save_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/easydiffusion/utils/save_utils.py b/ui/easydiffusion/utils/save_utils.py index 49743554..89dae991 100644 --- a/ui/easydiffusion/utils/save_utils.py +++ b/ui/easydiffusion/utils/save_utils.py @@ -21,6 +21,8 @@ TASK_TEXT_MAPPING = { "seed": "Seed", "use_stable_diffusion_model": "Stable Diffusion model", "clip_skip": "Clip Skip", + "use_controlnet_model": "ControlNet model", + "control_filter_to_apply": "ControlNet Filter", "use_vae_model": "VAE model", "sampler_name": "Sampler", "width": "Width", @@ -260,10 +262,12 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData, output del metadata["lora_alpha"] if task_data.use_upscale != "latent_upscaler" and "latent_upscaler_steps" in metadata: del metadata["latent_upscaler_steps"] + if task_data.use_controlnet_model is None and "control_filter_to_apply" in metadata: + del metadata["control_filter_to_apply"] if not using_diffusers: for key in ( - x for x in ["use_lora_model", "lora_alpha", "clip_skip", "tiling", "latent_upscaler_steps"] if x in metadata + x for x in ["use_lora_model", "lora_alpha", "clip_skip", "tiling", "latent_upscaler_steps", "use_controlnet_model", "control_filter_to_apply"] if x in metadata ): del metadata[key] From d76930c7f41f76b23b14c9616ca821052162f186 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 12:35:44 +0530 Subject: [PATCH 13/33] sdkit 1.0.159 - typo in TensorRT forward --- scripts/check_modules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_modules.py b/scripts/check_modules.py index b4da8c58..cd19f95b 100644 --- a/scripts/check_modules.py +++ b/scripts/check_modules.py @@ -18,7 +18,7 @@ os_name = platform.system() modules_to_check = { "torch": ("1.11.0", "1.13.1", "2.0.0"), "torchvision": ("0.12.0", "0.14.1", "0.15.1"), - "sdkit": "1.0.158", + "sdkit": "1.0.159", "stable-diffusion-sdkit": "2.1.4", "rich": "12.6.0", "uvicorn": "0.19.0", From d1fdf1766a81bdbf20f159032372d635a39b426b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 14:03:59 +0530 Subject: [PATCH 14/33] Allow batch size ranges again in TRT --- ui/media/js/main.js | 4 ++-- ui/media/js/parameters.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 3ec2723c..21e55923 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -1454,8 +1454,8 @@ function getCurrentUserRequest() { newTask.reqBody.convert_to_tensorrt = document.querySelector("#convert_to_tensorrt").checked let trtBuildConfig = { batch_size_range: [ - parseInt(document.querySelector("#trt-build-batch").value), - parseInt(document.querySelector("#trt-build-batch").value), + parseInt(document.querySelector("#trt-build-min-batch").value), + parseInt(document.querySelector("#trt-build-max-batch").value), ], dimensions_range: [], } diff --git a/ui/media/js/parameters.js b/ui/media/js/parameters.js index 96bcad87..8b66c461 100644 --- a/ui/media/js/parameters.js +++ b/ui/media/js/parameters.js @@ -251,7 +251,8 @@ var PARAMETERS = [ Early access version: support for LoRA is still under development.

Build Config:

- Batch size:

+ Min batch size:
+ Max batch size:

Build for resolutions:
512x512 to 768x768
768x768 to 1024x1024
From 801a3dd5989ca2d5f5aea7e5633802bb271baf2d Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 15:34:55 +0530 Subject: [PATCH 15/33] sdkit 1.0.160 - Dynamic load/unload of TensorRT engines --- scripts/check_modules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_modules.py b/scripts/check_modules.py index cd19f95b..f034ef31 100644 --- a/scripts/check_modules.py +++ b/scripts/check_modules.py @@ -18,7 +18,7 @@ os_name = platform.system() modules_to_check = { "torch": ("1.11.0", "1.13.1", "2.0.0"), "torchvision": ("0.12.0", "0.14.1", "0.15.1"), - "sdkit": "1.0.159", + "sdkit": "1.0.160", "stable-diffusion-sdkit": "2.1.4", "rich": "12.6.0", "uvicorn": "0.19.0", From 76b7e3212501e2bd2ca8fb8514454709bb4dec8f Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 16:37:05 +0530 Subject: [PATCH 16/33] Bug fixes for TRT --- ui/easydiffusion/tasks/render_images.py | 38 +++++++++++++++++++------ 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/ui/easydiffusion/tasks/render_images.py b/ui/easydiffusion/tasks/render_images.py index 8df208b6..ab0917d6 100644 --- a/ui/easydiffusion/tasks/render_images.py +++ b/ui/easydiffusion/tasks/render_images.py @@ -93,15 +93,27 @@ class RenderTask(Task): return model["params"].get(param_name) != new_val def trt_needs_reload(self, context): - if not self.has_param_changed(context, "convert_to_tensorrt"): + if not context.test_diffusers: return False + if "stable-diffusion" not in context.models or "params" not in context.models["stable-diffusion"]: + return True model = context.models["stable-diffusion"] - pipe = model["default"] - if hasattr(pipe.unet, "_allocate_trt_buffers"): # TRT already loaded - return False - return True + # curr_convert_to_trt = model["params"].get("convert_to_tensorrt") + new_convert_to_trt = self.models_data.model_params.get("stable-diffusion", {}).get("convert_to_tensorrt", False) + + pipe = model["default"] + is_trt_loaded = hasattr(pipe.unet, "_allocate_trt_buffers") or hasattr( + pipe.unet, "_allocate_trt_buffers_backup" + ) + if new_convert_to_trt and not is_trt_loaded: + return True + + curr_build_config = model["params"].get("trt_build_config") + new_build_config = self.models_data.model_params.get("stable-diffusion", {}).get("trt_build_config", {}) + + return new_convert_to_trt and curr_build_config != new_build_config def make_images( @@ -215,12 +227,20 @@ def generate_images_internal( if context.test_diffusers: pipe = context.models["stable-diffusion"]["default"] + if hasattr(pipe.unet, "_allocate_trt_buffers_backup"): + setattr(pipe.unet, "_allocate_trt_buffers", pipe.unet._allocate_trt_buffers_backup) + delattr(pipe.unet, "_allocate_trt_buffers_backup") + if hasattr(pipe.unet, "_allocate_trt_buffers"): convert_to_trt = models_data.model_params["stable-diffusion"].get("convert_to_tensorrt", False) - pipe.unet.forward = pipe.unet._trt_forward if convert_to_trt else pipe.unet._non_trt_forward - # pipe.vae.decoder.forward = ( - # pipe.vae.decoder._trt_forward if convert_to_trt else pipe.vae.decoder._non_trt_forward - # ) + if convert_to_trt: + pipe.unet.forward = pipe.unet._trt_forward + # pipe.vae.decoder.forward = pipe.vae.decoder._trt_forward + else: + pipe.unet.forward = pipe.unet._non_trt_forward + # pipe.vae.decoder.forward = pipe.vae.decoder._non_trt_forward + setattr(pipe.unet, "_allocate_trt_buffers_backup", pipe.unet._allocate_trt_buffers) + delattr(pipe.unet, "_allocate_trt_buffers") images = generate_images(context, callback=callback, **req.dict()) user_stopped = False From b6344ef6f90041d39e9d02ddd72d53c93d788ad8 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 16:37:19 +0530 Subject: [PATCH 17/33] sdkit 1.0.161 - bug fixes for TRT --- scripts/check_modules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_modules.py b/scripts/check_modules.py index f034ef31..7e15f5d3 100644 --- a/scripts/check_modules.py +++ b/scripts/check_modules.py @@ -18,7 +18,7 @@ os_name = platform.system() modules_to_check = { "torch": ("1.11.0", "1.13.1", "2.0.0"), "torchvision": ("0.12.0", "0.14.1", "0.15.1"), - "sdkit": "1.0.160", + "sdkit": "1.0.161", "stable-diffusion-sdkit": "2.1.4", "rich": "12.6.0", "uvicorn": "0.19.0", From 9be3297c27c8f07fc01c5fb3b2eb825bf937e581 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 16:42:24 +0530 Subject: [PATCH 18/33] sdkit 1.0.162 - bug fixes for TRT --- scripts/check_modules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_modules.py b/scripts/check_modules.py index 7e15f5d3..16783e40 100644 --- a/scripts/check_modules.py +++ b/scripts/check_modules.py @@ -18,7 +18,7 @@ os_name = platform.system() modules_to_check = { "torch": ("1.11.0", "1.13.1", "2.0.0"), "torchvision": ("0.12.0", "0.14.1", "0.15.1"), - "sdkit": "1.0.161", + "sdkit": "1.0.162", "stable-diffusion-sdkit": "2.1.4", "rich": "12.6.0", "uvicorn": "0.19.0", From c5249e61446c3cacf2e58f05e4d33e0ce35fa09b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 16:45:12 +0530 Subject: [PATCH 19/33] TRT styling --- ui/media/js/parameters.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/media/js/parameters.js b/ui/media/js/parameters.js index 8b66c461..b97356ec 100644 --- a/ui/media/js/parameters.js +++ b/ui/media/js/parameters.js @@ -251,8 +251,9 @@ var PARAMETERS = [ Early access version: support for LoRA is still under development.

Build Config:

- Min batch size:
- Max batch size:

+ Batch size range: + +

Build for resolutions:
512x512 to 768x768
768x768 to 1024x1024
From befe8ad24e168c37617ff9b665b8ab24eafe0b9b Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 18:55:09 +0530 Subject: [PATCH 20/33] TRT logging --- ui/easydiffusion/tasks/render_images.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/easydiffusion/tasks/render_images.py b/ui/easydiffusion/tasks/render_images.py index ab0917d6..bf263b3f 100644 --- a/ui/easydiffusion/tasks/render_images.py +++ b/ui/easydiffusion/tasks/render_images.py @@ -15,6 +15,7 @@ from sdkit.utils import ( img_to_base64_str, img_to_buffer, latent_samples_to_images, + log, ) from .task import Task @@ -236,7 +237,9 @@ def generate_images_internal( if convert_to_trt: pipe.unet.forward = pipe.unet._trt_forward # pipe.vae.decoder.forward = pipe.vae.decoder._trt_forward + log.info(f"Setting unet.forward to TensorRT") else: + log.info(f"Not using TensorRT for unet.forward") pipe.unet.forward = pipe.unet._non_trt_forward # pipe.vae.decoder.forward = pipe.vae.decoder._non_trt_forward setattr(pipe.unet, "_allocate_trt_buffers_backup", pipe.unet._allocate_trt_buffers) From 83c93eb9efa1700ddbdd64efedd5523f751baae0 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Aug 2023 21:53:11 +0530 Subject: [PATCH 21/33] sdkit 1.0.163 - trt multi-gpu fix --- scripts/check_modules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_modules.py b/scripts/check_modules.py index 16783e40..3d838d2b 100644 --- a/scripts/check_modules.py +++ b/scripts/check_modules.py @@ -18,7 +18,7 @@ os_name = platform.system() modules_to_check = { "torch": ("1.11.0", "1.13.1", "2.0.0"), "torchvision": ("0.12.0", "0.14.1", "0.15.1"), - "sdkit": "1.0.162", + "sdkit": "1.0.163", "stable-diffusion-sdkit": "2.1.4", "rich": "12.6.0", "uvicorn": "0.19.0", From f0f6578b9ce625bc118374d168d18caa06ad0864 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 10:22:24 +0530 Subject: [PATCH 22/33] Round image sizes to a multiple of 8 --- ui/easydiffusion/tasks/render_images.py | 2 ++ ui/media/js/main.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/easydiffusion/tasks/render_images.py b/ui/easydiffusion/tasks/render_images.py index bf263b3f..bdf6e3ac 100644 --- a/ui/easydiffusion/tasks/render_images.py +++ b/ui/easydiffusion/tasks/render_images.py @@ -223,6 +223,8 @@ def generate_images_internal( if req.init_image is not None and not context.test_diffusers: req.sampler_name = "ddim" + req.width, req.height = map(lambda x: x - x % 8, (req.width, req.height)) # clamp to 8 + if req.control_image and task_data.control_filter_to_apply: req.control_image = filter_images(context, req.control_image, task_data.control_filter_to_apply)[0] diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 21e55923..568ab0dc 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -1365,6 +1365,12 @@ function getCurrentUserRequest() { // numOutputsParallel = 1 // force 1 parallel // } + // clamp to multiple of 8 + let width = parseInt(widthField.value) + let height = parseInt(heightField.value) + width = width - (width % 8) + height = height - (height % 8) + const newTask = { batchesDone: 0, numOutputsTotal: numOutputsTotal, @@ -1377,8 +1383,8 @@ function getCurrentUserRequest() { num_outputs: numOutputsParallel, num_inference_steps: parseInt(numInferenceStepsField.value), guidance_scale: parseFloat(guidanceScaleField.value), - width: parseInt(widthField.value), - height: parseInt(heightField.value), + width: width, + height: height, // allow_nsfw: allowNSFWField.checked, vram_usage_level: vramUsageLevelField.value, sampler_name: samplerField.value, From 6a95c602b1fca684c2d144253374f852093f5a2e Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 12:43:30 +0530 Subject: [PATCH 23/33] sdkit 1.0.164 - Warn the user if the controlnet isn't compatible with the SD model version --- scripts/check_modules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_modules.py b/scripts/check_modules.py index 3d838d2b..278294b7 100644 --- a/scripts/check_modules.py +++ b/scripts/check_modules.py @@ -18,7 +18,7 @@ os_name = platform.system() modules_to_check = { "torch": ("1.11.0", "1.13.1", "2.0.0"), "torchvision": ("0.12.0", "0.14.1", "0.15.1"), - "sdkit": "1.0.163", + "sdkit": "1.0.164", "stable-diffusion-sdkit": "2.1.4", "rich": "12.6.0", "uvicorn": "0.19.0", From 9a528496a34eb35ce2f67a5cf3a53c7bddcd3167 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 15:13:41 +0530 Subject: [PATCH 24/33] Reload the model if the path exists in the request but the model has been unloaded --- ui/easydiffusion/model_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/easydiffusion/model_manager.py b/ui/easydiffusion/model_manager.py index 63f79859..845e9126 100644 --- a/ui/easydiffusion/model_manager.py +++ b/ui/easydiffusion/model_manager.py @@ -148,7 +148,7 @@ def reload_models_if_necessary(context: Context, models_data: ModelsData, models models_to_reload = { model_type: path for model_type, path in models_data.model_paths.items() - if context.model_paths.get(model_type) != path + if context.model_paths.get(model_type) != path or (path is not None and context.models.get(model_type) is None) } if models_data.model_paths.get("codeformer"): From b8328b6071b61ae580e87448bb1df8c921259ca6 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 15:14:00 +0530 Subject: [PATCH 25/33] sdkit 1.0.165 - warn users about incompatible loras --- scripts/check_modules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_modules.py b/scripts/check_modules.py index 278294b7..04d1309b 100644 --- a/scripts/check_modules.py +++ b/scripts/check_modules.py @@ -18,7 +18,7 @@ os_name = platform.system() modules_to_check = { "torch": ("1.11.0", "1.13.1", "2.0.0"), "torchvision": ("0.12.0", "0.14.1", "0.15.1"), - "sdkit": "1.0.164", + "sdkit": "1.0.165", "stable-diffusion-sdkit": "2.1.4", "rich": "12.6.0", "uvicorn": "0.19.0", From b97c90612852852ddd3654812f1dc77fe1927019 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 15:49:01 +0530 Subject: [PATCH 26/33] Fix a bug where setting an initial image would mess up the width and height field --- ui/media/js/main.js | 1 + .../ui/image-editor-improvements.plugin.js | 30 ++++--------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 568ab0dc..319e5861 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -2162,6 +2162,7 @@ function checkRandomSeed() { randomSeedField.addEventListener("input", checkRandomSeed) checkRandomSeed() +// warning: the core plugin `image-editor-improvements.js:172` replaces loadImg2ImgFromFile() with a custom version function loadImg2ImgFromFile() { if (initImageSelector.files.length === 0) { return diff --git a/ui/plugins/ui/image-editor-improvements.plugin.js b/ui/plugins/ui/image-editor-improvements.plugin.js index 7435df8b..aededb8d 100644 --- a/ui/plugins/ui/image-editor-improvements.plugin.js +++ b/ui/plugins/ui/image-editor-improvements.plugin.js @@ -124,35 +124,17 @@ // Draw the image with centered coordinates context.drawImage(imageObj, x, y, this.width, this.height); - initImagePreview.src = canvas.toDataURL('image/png'); + let bestWidth = maxCroppedWidth - maxCroppedWidth % 8 + let bestHeight = maxCroppedHeight - maxCroppedHeight % 8 - // Get the options from widthField and heightField - const widthOptions = Array.from(widthField.options).map(option => parseInt(option.value)); - const heightOptions = Array.from(heightField.options).map(option => parseInt(option.value)); - - // Find the closest aspect ratio and closest to original dimensions - let bestWidth = widthOptions[0]; - let bestHeight = heightOptions[0]; - let minDifference = Math.abs(maxCroppedWidth / maxCroppedHeight - bestWidth / bestHeight); - let minDistance = Math.abs(maxCroppedWidth - bestWidth) + Math.abs(maxCroppedHeight - bestHeight); - - for (const width of widthOptions) { - for (const height of heightOptions) { - const difference = Math.abs(maxCroppedWidth / maxCroppedHeight - width / height); - const distance = Math.abs(maxCroppedWidth - width) + Math.abs(maxCroppedHeight - height); - - if (difference < minDifference || (difference === minDifference && distance < minDistance)) { - minDifference = difference; - minDistance = distance; - bestWidth = width; - bestHeight = height; - } - } - } + addImageSizeOption(bestWidth) + addImageSizeOption(bestHeight) // Set the width and height to the closest aspect ratio and closest to original dimensions widthField.value = bestWidth; heightField.value = bestHeight; + + initImagePreview.src = canvas.toDataURL('image/png'); }; function handlePaste(e) { From 83a5b5b46fb0a9acad1d9afc8a5ef5f6c9f874aa Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 15:51:39 +0530 Subject: [PATCH 27/33] Clamp controlnet images to multiples of 8 --- ui/media/js/main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 319e5861..d1fa177f 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -2245,6 +2245,9 @@ controlImageSelector.addEventListener("change", loadControlnetImageFromFile) function controlImageLoad() { let w = controlImagePreview.naturalWidth let h = controlImagePreview.naturalHeight + w = w - (w % 8) + h = h - (h % 8) + addImageSizeOption(w) addImageSizeOption(h) From 3929e88d87597120ef891ca1655b555977e5d1ec Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 16:20:27 +0530 Subject: [PATCH 28/33] Include the lora parser plugin as a core feature --- ui/plugins/ui/lora-prompt-parser.plugin.js | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 ui/plugins/ui/lora-prompt-parser.plugin.js diff --git a/ui/plugins/ui/lora-prompt-parser.plugin.js b/ui/plugins/ui/lora-prompt-parser.plugin.js new file mode 100644 index 00000000..5030b74c --- /dev/null +++ b/ui/plugins/ui/lora-prompt-parser.plugin.js @@ -0,0 +1,114 @@ +/* + LoRA Prompt Parser 1.0 + by Patrice + + Copying and pasting a prompt with a LoRA tag will automatically select the corresponding option in the Easy Diffusion dropdown and remove the LoRA tag from the prompt. The LoRA must be already available in the corresponding Easy Diffusion dropdown (this is not a LoRA downloader). +*/ +(function() { + "use strict" + + promptField.addEventListener('input', function(e) { + const { LoRA, prompt } = extractLoraTags(e.target.value); + //console.log('e.target: ' + JSON.stringify(LoRA)); + + if (LoRA !== null && LoRA.length > 0) { + promptField.value = prompt.replace(/,+$/, ''); // remove any trailing , + + if (testDiffusers?.checked === false) { + showToast("LoRA's are only supported with diffusers. Just stripping the LoRA tag from the prompt.") + } + } + + if (LoRA !== null && LoRA.length > 0 && testDiffusers?.checked) { + for (let i = 0; i < LoRA.length; i++) { + //if (loraModelField.value !== LoRA[0].lora_model) { + // Set the new LoRA value + //console.log("Loading info"); + //console.log(LoRA[0].lora_model_0); + //console.log(JSON.stringify(LoRa)); + + let lora = `lora_model_${i}`; + let alpha = `lora_alpha_${i}`; + let loramodel = document.getElementById(lora); + let alphavalue = document.getElementById(alpha); + loramodel.setAttribute("data-path", LoRA[i].lora_model_0); + loramodel.value = LoRA[i].lora_model_0; + alphavalue.value = LoRA[i].lora_alpha_0; + if (i != LoRA.length - 1) + createLoraEntry(); + } + //loraAlphaSlider.value = loraAlphaField.value * 100; + //TBD.value = LoRA[0].blockweights; // block weights not supported by ED at this time + //} + showToast("Prompt successfully processed", LoRA[0].lora_model_0); + //console.log('LoRa: ' + LoRA[0].lora_model_0); + //showToast("Prompt successfully processed", lora_model_0.value); + + } + + //promptField.dispatchEvent(new Event('change')); + }); + + function isModelAvailable(array, searchString) { + const foundItem = array.find(function(item) { + item = item.toString().toLowerCase(); + return item === searchString.toLowerCase() + }); + + return foundItem || ""; + } + + // extract LoRA tags from strings + function extractLoraTags(prompt) { + // Define the regular expression for the tags + const regex = /<(?:lora|lyco):([^:>]+)(?::([^:>]*))?(?::([^:>]*))?>/gi + + // Initialize an array to hold the matches + let matches = [] + + // Iterate over the string, finding matches + for (const match of prompt.matchAll(regex)) { + const modelFileName = isModelAvailable(modelsCache.options.lora, match[1].trim()) + if (modelFileName !== "") { + // Initialize an object to hold a match + let loraTag = { + lora_model_0: modelFileName, + } + //console.log("Model:" + modelFileName); + + // If weight is provided, add it to the loraTag object + if (match[2] !== undefined && match[2] !== '') { + loraTag.lora_alpha_0 = parseFloat(match[2].trim()) + } + else + { + loraTag.lora_alpha_0 = 0.5 + } + + + // If blockweights are provided, add them to the loraTag object + if (match[3] !== undefined && match[3] !== '') { + loraTag.blockweights = match[3].trim() + } + + // Add the loraTag object to the array of matches + matches.push(loraTag); + //console.log(JSON.stringify(matches)); + } + else + { + showToast("LoRA not found: " + match[1].trim(), 5000, true) + } + } + + // Clean up the prompt string, e.g. from "apple, banana, , orange, , pear , " to "apple, banana, orange, pear" + let cleanedPrompt = prompt.replace(regex, '').replace(/(\s*,\s*(?=\s*,|$))|(^\s*,\s*)|\s+/g, ' ').trim(); + //console.log('Matches: ' + JSON.stringify(matches)); + + // Return the array of matches and cleaned prompt string + return { + LoRA: matches, + prompt: cleanedPrompt + } + } +})() From 404329f9b5a438740dade298378125e9b273d0ec Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 16:33:20 +0530 Subject: [PATCH 29/33] Fix for image modifier improvements plugin --- ui/media/css/main.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/media/css/main.css b/ui/media/css/main.css index 3e07448e..2e7d7da9 100644 --- a/ui/media/css/main.css +++ b/ui/media/css/main.css @@ -1826,4 +1826,9 @@ div#enlarge-buttons { } #controlnet_model { width: 77%; +} + +/* hack for fixing Image Modifier Improvements plugin */ +#imageTagPopupContainer { + position: absolute; } \ No newline at end of file From d35a89bb010dbd57c76dba43522adfae35169c49 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 17:08:21 +0530 Subject: [PATCH 30/33] Show the controlnet buttons only for diffusers --- ui/index.html | 111 +++++++++++++++++++------------------- ui/media/js/parameters.js | 2 + 2 files changed, 59 insertions(+), 54 deletions(-) diff --git a/ui/index.html b/ui/index.html index 8bc2a0ba..7cedc0e5 100644 --- a/ui/index.html +++ b/ui/index.html @@ -161,60 +161,63 @@ Click to learn more about Clip Skip - -
- - - -
- - Click to learn more about ControlNets -
- - -
- -
- -
- + + + +
+ + + +
+ + Click to learn more about ControlNets +
+ + +
+ +
+ +
+ + Click to learn more about VAEs diff --git a/ui/media/js/parameters.js b/ui/media/js/parameters.js index b97356ec..8ff902a9 100644 --- a/ui/media/js/parameters.js +++ b/ui/media/js/parameters.js @@ -461,6 +461,7 @@ async function getAppConfig() { if (!testDiffusersEnabled) { document.querySelector("#lora_model_container").style.display = "none" document.querySelector("#tiling_container").style.display = "none" + document.querySelector("#controlnet_model_container").style.display = "none" document.querySelectorAll("#sampler_name option.diffusers-only").forEach((option) => { option.style.display = "none" @@ -470,6 +471,7 @@ async function getAppConfig() { } else { document.querySelector("#lora_model_container").style.display = "" document.querySelector("#tiling_container").style.display = "" + document.querySelector("#controlnet_model_container").style.display = "" document.querySelectorAll("#sampler_name option.k_diffusion-only").forEach((option) => { option.style.display = "none" From 376d238ad8e611972421f5a822824132c2a604eb Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 17:40:26 +0530 Subject: [PATCH 31/33] Keep IMAGE_STEP_SIZE synchronized across all the clamps --- ui/media/js/main.js | 10 ++++++---- ui/media/js/parameters.js | 12 ++++++++---- ui/plugins/ui/image-editor-improvements.plugin.js | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index d1fa177f..802cfb55 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -183,6 +183,8 @@ let undoBuffer = [] const UNDO_LIMIT = 20 const MAX_IMG_UNDO_ENTRIES = 5 +let IMAGE_STEP_SIZE = 64 + let loraModels = [] imagePreview.addEventListener("drop", function(ev) { @@ -1368,8 +1370,8 @@ function getCurrentUserRequest() { // clamp to multiple of 8 let width = parseInt(widthField.value) let height = parseInt(heightField.value) - width = width - (width % 8) - height = height - (height % 8) + width = width - (width % IMAGE_STEP_SIZE) + height = height - (height % IMAGE_STEP_SIZE) const newTask = { batchesDone: 0, @@ -2245,8 +2247,8 @@ controlImageSelector.addEventListener("change", loadControlnetImageFromFile) function controlImageLoad() { let w = controlImagePreview.naturalWidth let h = controlImagePreview.naturalHeight - w = w - (w % 8) - h = h - (h % 8) + w = w - (w % IMAGE_STEP_SIZE) + h = h - (h % IMAGE_STEP_SIZE) addImageSizeOption(w) addImageSizeOption(h) diff --git a/ui/media/js/parameters.js b/ui/media/js/parameters.js index 8ff902a9..098eb908 100644 --- a/ui/media/js/parameters.js +++ b/ui/media/js/parameters.js @@ -462,16 +462,19 @@ async function getAppConfig() { document.querySelector("#lora_model_container").style.display = "none" document.querySelector("#tiling_container").style.display = "none" document.querySelector("#controlnet_model_container").style.display = "none" + document.querySelector("#hypernetwork_strength_container").style.display = "" document.querySelectorAll("#sampler_name option.diffusers-only").forEach((option) => { option.style.display = "none" }) - customWidthField.step = 64 - customHeightField.step = 64 + IMAGE_STEP_SIZE = 64 + customWidthField.step = IMAGE_STEP_SIZE + customHeightField.step = IMAGE_STEP_SIZE } else { document.querySelector("#lora_model_container").style.display = "" document.querySelector("#tiling_container").style.display = "" document.querySelector("#controlnet_model_container").style.display = "" + document.querySelector("#hypernetwork_strength_container").style.display = "none" document.querySelectorAll("#sampler_name option.k_diffusion-only").forEach((option) => { option.style.display = "none" @@ -479,8 +482,9 @@ async function getAppConfig() { document.querySelector("#clip_skip_config").classList.remove("displayNone") document.querySelector("#embeddings-button").classList.remove("displayNone") document.querySelector("#negative-embeddings-button").classList.remove("displayNone") - customWidthField.step = 8 - customHeightField.step = 8 + IMAGE_STEP_SIZE = 8 + customWidthField.step = IMAGE_STEP_SIZE + customHeightField.step = IMAGE_STEP_SIZE } console.log("get config status response", config) diff --git a/ui/plugins/ui/image-editor-improvements.plugin.js b/ui/plugins/ui/image-editor-improvements.plugin.js index aededb8d..fbc7ad80 100644 --- a/ui/plugins/ui/image-editor-improvements.plugin.js +++ b/ui/plugins/ui/image-editor-improvements.plugin.js @@ -124,8 +124,8 @@ // Draw the image with centered coordinates context.drawImage(imageObj, x, y, this.width, this.height); - let bestWidth = maxCroppedWidth - maxCroppedWidth % 8 - let bestHeight = maxCroppedHeight - maxCroppedHeight % 8 + let bestWidth = maxCroppedWidth - maxCroppedWidth % IMAGE_STEP_SIZE + let bestHeight = maxCroppedHeight - maxCroppedHeight % IMAGE_STEP_SIZE addImageSizeOption(bestWidth) addImageSizeOption(bestHeight) From cc7452374d33c28c5a74736477f70617cc6cbcec Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 17:43:49 +0530 Subject: [PATCH 32/33] Remove hypernetworks from the UI options in diffusers. Sorry --- ui/index.html | 2 +- ui/media/js/parameters.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/index.html b/ui/index.html index 7cedc0e5..856150c6 100644 --- a/ui/index.html +++ b/ui/index.html @@ -324,7 +324,7 @@ - + diff --git a/ui/media/js/parameters.js b/ui/media/js/parameters.js index 098eb908..9db01807 100644 --- a/ui/media/js/parameters.js +++ b/ui/media/js/parameters.js @@ -462,6 +462,7 @@ async function getAppConfig() { document.querySelector("#lora_model_container").style.display = "none" document.querySelector("#tiling_container").style.display = "none" document.querySelector("#controlnet_model_container").style.display = "none" + document.querySelector("#hypernetwork_model_container").style.display = "" document.querySelector("#hypernetwork_strength_container").style.display = "" document.querySelectorAll("#sampler_name option.diffusers-only").forEach((option) => { @@ -474,6 +475,7 @@ async function getAppConfig() { document.querySelector("#lora_model_container").style.display = "" document.querySelector("#tiling_container").style.display = "" document.querySelector("#controlnet_model_container").style.display = "" + document.querySelector("#hypernetwork_model_container").style.display = "none" document.querySelector("#hypernetwork_strength_container").style.display = "none" document.querySelectorAll("#sampler_name option.k_diffusion-only").forEach((option) => { From 21297d98f24a05b5624dc728d88e60f4fc1e37ef Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 3 Aug 2023 18:38:25 +0530 Subject: [PATCH 33/33] Option to disable LoRA tag parsing --- ui/media/js/auto-save.js | 1 + ui/media/js/parameters.js | 9 +++++++++ ui/plugins/ui/lora-prompt-parser.plugin.js | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/ui/media/js/auto-save.js b/ui/media/js/auto-save.js index 670fee0d..f70b19c7 100644 --- a/ui/media/js/auto-save.js +++ b/ui/media/js/auto-save.js @@ -54,6 +54,7 @@ const SETTINGS_IDS_LIST = [ "zip_toggle", "tree_toggle", "json_toggle", + "extract_lora_from_prompt", ] const IGNORE_BY_DEFAULT = ["prompt"] diff --git a/ui/media/js/parameters.js b/ui/media/js/parameters.js index 9db01807..671451eb 100644 --- a/ui/media/js/parameters.js +++ b/ui/media/js/parameters.js @@ -121,6 +121,15 @@ var PARAMETERS = [ icon: "fa-arrow-down-short-wide", default: false, }, + { + id: "extract_lora_from_prompt", + type: ParameterType.checkbox, + label: "Extract LoRA tags from the prompt", + note: + "Automatically extract lora tags like <lora:name:0.4> from the prompt, and apply the correct LoRA (if present)", + icon: "fa-code", + default: true, + }, { id: "ui_open_browser_on_start", type: ParameterType.checkbox, diff --git a/ui/plugins/ui/lora-prompt-parser.plugin.js b/ui/plugins/ui/lora-prompt-parser.plugin.js index 5030b74c..201d49af 100644 --- a/ui/plugins/ui/lora-prompt-parser.plugin.js +++ b/ui/plugins/ui/lora-prompt-parser.plugin.js @@ -8,6 +8,11 @@ "use strict" promptField.addEventListener('input', function(e) { + let loraExtractSetting = document.getElementById("extract_lora_from_prompt") + if (!loraExtractSetting.checked) { + return + } + const { LoRA, prompt } = extractLoraTags(e.target.value); //console.log('e.target: ' + JSON.stringify(LoRA));