From 44789bf16bb2bb32c7edfb8c360ea85adaa6a4c4 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 28 May 2024 18:45:08 +0530 Subject: [PATCH] sdkit 2.0.15.4 - Controlnet strength slider --- scripts/check_modules.py | 2 +- ui/easydiffusion/utils/save_utils.py | 1 + ui/index.html | 4 +++- ui/media/js/auto-save.js | 1 + ui/media/js/dnd.js | 10 ++++++++++ ui/media/js/main.js | 28 ++++++++++++++++++++++++++++ 6 files changed, 44 insertions(+), 2 deletions(-) diff --git a/scripts/check_modules.py b/scripts/check_modules.py index 50ff90c2..23dac713 100644 --- a/scripts/check_modules.py +++ b/scripts/check_modules.py @@ -22,7 +22,7 @@ modules_to_check = { "torch": ("1.11.0", "1.13.1", "2.0.0", "2.0.1"), "torchvision": ("0.12.0", "0.14.1", "0.15.1", "0.15.2"), "setuptools": "69.5.1", - "sdkit": "2.0.15.3", + "sdkit": "2.0.15.4", "diffusers": "0.21.4", "stable-diffusion-sdkit": "2.1.5", "rich": "12.6.0", diff --git a/ui/easydiffusion/utils/save_utils.py b/ui/easydiffusion/utils/save_utils.py index 457af921..e1b4d79a 100644 --- a/ui/easydiffusion/utils/save_utils.py +++ b/ui/easydiffusion/utils/save_utils.py @@ -31,6 +31,7 @@ TASK_TEXT_MAPPING = { "clip_skip": "Clip Skip", "use_controlnet_model": "ControlNet model", "control_filter_to_apply": "ControlNet Filter", + "control_alpha": "ControlNet Strength", "use_vae_model": "VAE model", "sampler_name": "Sampler", "width": "Width", diff --git a/ui/index.html b/ui/index.html index 77113985..a8c6685f 100644 --- a/ui/index.html +++ b/ui/index.html @@ -35,7 +35,7 @@

Easy Diffusion - v3.0.8 + v3.0.9

@@ -235,6 +235,8 @@
+
+
diff --git a/ui/media/js/auto-save.js b/ui/media/js/auto-save.js index 47a2885b..4ed28b89 100644 --- a/ui/media/js/auto-save.js +++ b/ui/media/js/auto-save.js @@ -57,6 +57,7 @@ const SETTINGS_IDS_LIST = [ "embedding-card-size-selector", "lora_model", "enable_vae_tiling", + "controlnet_alpha", ] const IGNORE_BY_DEFAULT = ["prompt"] diff --git a/ui/media/js/dnd.js b/ui/media/js/dnd.js index cf082406..0a547e55 100644 --- a/ui/media/js/dnd.js +++ b/ui/media/js/dnd.js @@ -309,6 +309,15 @@ const TASK_MAPPING = { readUI: () => controlImageFilterField.value, parse: (val) => val, }, + control_alpha: { + name: "ControlNet Strength", + setUI: (control_alpha) => { + controlAlphaField.value = control_alpha + updateControlAlphaSlider() + }, + readUI: () => parseFloat(controlAlphaField.value), + parse: (val) => parseFloat(val), + }, use_lora_model: { name: "LoRA model", setUI: (use_lora_model) => { @@ -587,6 +596,7 @@ const TASK_TEXT_MAPPING = { lora_alpha: "LoRA Strength", use_controlnet_model: "ControlNet model", control_filter_to_apply: "ControlNet Filter", + control_alpha: "ControlNet Strength", tiling: "Seamless Tiling", } function parseTaskFromText(str) { diff --git a/ui/media/js/main.js b/ui/media/js/main.js index ede271df..bff87b3b 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -51,6 +51,10 @@ const taskConfigSetup = { preserve_init_image_color_profile: "Preserve Color Profile", strict_mask_border: "Strict Mask Border", use_controlnet_model: "ControlNet Model", + control_alpha: { + label: "ControlNet Strength", + visible: ({ reqBody }) => !!reqBody?.use_controlnet_model, + }, }, pluginTaskConfig: {}, getCSSKey: (key) => @@ -99,6 +103,8 @@ let controlImagePreview = document.querySelector("#control_image_preview") let controlImageClearBtn = document.querySelector(".control_image_clear") let controlImageContainer = document.querySelector("#control_image_wrapper") let controlImageFilterField = document.querySelector("#control_image_filter") +let controlAlphaSlider = document.querySelector("#controlnet_alpha_slider") +let controlAlphaField = document.querySelector("#controlnet_alpha") let applyColorCorrectionField = document.querySelector("#apply_color_correction") let strictMaskBorderField = document.querySelector("#strict_mask_border") let colorCorrectionSetting = document.querySelector("#apply_color_correction_setting") @@ -1395,6 +1401,7 @@ function getCurrentUserRequest() { if (controlnetModelField.value !== "" && IMAGE_REGEX.test(controlImagePreview.src)) { newTask.reqBody.use_controlnet_model = controlnetModelField.value newTask.reqBody.control_image = controlImagePreview.src + newTask.reqBody.control_alpha = parseFloat(controlAlphaField.value) if (controlImageFilterField.value !== "") { newTask.reqBody.control_filter_to_apply = controlImageFilterField.value } @@ -2015,6 +2022,27 @@ function updateHypernetworkStrengthContainer() { hypernetworkModelField.addEventListener("change", updateHypernetworkStrengthContainer) updateHypernetworkStrengthContainer() +/********************* Controlnet Alpha **************************/ +function updateControlAlpha() { + controlAlphaField.value = controlAlphaSlider.value / 10 + controlAlphaField.dispatchEvent(new Event("change")) +} + +function updateControlAlphaSlider() { + if (controlAlphaField.value < 0) { + controlAlphaField.value = 0 + } else if (controlAlphaField.value > 10) { + controlAlphaField.value = 10 + } + + controlAlphaSlider.value = controlAlphaField.value * 10 + controlAlphaSlider.dispatchEvent(new Event("change")) +} + +controlAlphaSlider.addEventListener("input", updateControlAlpha) +controlAlphaField.addEventListener("input", updateControlAlphaSlider) +updateControlAlpha() + /********************* JPEG/WEBP Quality **********************/ function updateOutputQuality() { outputQualityField.value = 0 | outputQualitySlider.value