Set the controlnet alpha correctly from older exports; Fix a bug with null lora model in exports

This commit is contained in:
cmdr2 2024-05-28 19:16:48 +05:30
parent 4d9b023378
commit 05f3523364

View File

@ -312,16 +312,18 @@ const TASK_MAPPING = {
control_alpha: { control_alpha: {
name: "ControlNet Strength", name: "ControlNet Strength",
setUI: (control_alpha) => { setUI: (control_alpha) => {
control_alpha = control_alpha || 1.0
controlAlphaField.value = control_alpha controlAlphaField.value = control_alpha
updateControlAlphaSlider() updateControlAlphaSlider()
}, },
readUI: () => parseFloat(controlAlphaField.value), readUI: () => parseFloat(controlAlphaField.value),
parse: (val) => parseFloat(val), parse: (val) => val === null ? 1.0 : parseFloat(val),
}, },
use_lora_model: { use_lora_model: {
name: "LoRA model", name: "LoRA model",
setUI: (use_lora_model) => { setUI: (use_lora_model) => {
let modelPaths = [] 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 = Array.isArray(use_lora_model) ? use_lora_model : [use_lora_model]
use_lora_model.forEach((m) => { use_lora_model.forEach((m) => {
if (m.includes("models\\lora\\")) { 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 // listen for inpainter loading event, which happens AFTER the main image loads (which reloads the inpai
controlImagePreview.src = task.reqBody.control_image 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() { function readUI() {
const reqBody = {} const reqBody = {}