From 05f3523364770f8aa8253c16b33ff2b627a67ff1 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Tue, 28 May 2024 19:16:48 +0530 Subject: [PATCH] Set the controlnet alpha correctly from older exports; Fix a bug with null lora model in exports --- ui/media/js/dnd.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/media/js/dnd.js b/ui/media/js/dnd.js index 0a547e55..5cb517fe 100644 --- a/ui/media/js/dnd.js +++ b/ui/media/js/dnd.js @@ -312,16 +312,18 @@ const TASK_MAPPING = { control_alpha: { name: "ControlNet Strength", setUI: (control_alpha) => { + control_alpha = control_alpha || 1.0 controlAlphaField.value = control_alpha updateControlAlphaSlider() }, readUI: () => parseFloat(controlAlphaField.value), - parse: (val) => parseFloat(val), + parse: (val) => val === null ? 1.0 : parseFloat(val), }, use_lora_model: { name: "LoRA model", setUI: (use_lora_model) => { let modelPaths = [] + use_lora_model = use_lora_model === null ? "" : use_lora_model use_lora_model = Array.isArray(use_lora_model) ? use_lora_model : [use_lora_model] use_lora_model.forEach((m) => { if (m.includes("models\\lora\\")) { @@ -538,6 +540,11 @@ function restoreTaskToUI(task, fieldsToSkip) { // listen for inpainter loading event, which happens AFTER the main image loads (which reloads the inpai controlImagePreview.src = task.reqBody.control_image } + + if ("use_controlnet_model" in task.reqBody && task.reqBody.use_controlnet_model && !("control_alpha" in task.reqBody)) { + controlAlphaField.value = 1.0 + updateControlAlphaSlider() + } } function readUI() { const reqBody = {}