From 38b2eec4befdff19382defcae24afacc1a9e0b07 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 18 Aug 2023 16:14:01 +0530 Subject: [PATCH] Show controlnet preview in the task entry after applying the filter --- ui/media/js/main.js | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 08b53ebb..281f4b49 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -1446,12 +1446,12 @@ function createTask(task) { if (task.reqBody.init_image !== undefined) { let h = 80 let w = ((task.reqBody.width * h) / task.reqBody.height) >> 0 - taskConfig += `
` + taskConfig += `
` } if (task.reqBody.control_image !== undefined) { let h = 80 let w = ((task.reqBody.width * h) / task.reqBody.height) >> 0 - taskConfig += `
` + taskConfig += `
` } taskConfig += `
${createTaskConfig(task)}
` @@ -1473,6 +1473,30 @@ function createTask(task) {
` + if (task.reqBody.init_image !== undefined || task.reqBody.control_image !== undefined) { + createInitImageHover(taskEntry) + } + + if (task.reqBody.control_image !== undefined && task.reqBody.control_filter_to_apply !== undefined) { + let controlImagePreview = taskEntry.querySelector(".controlnet-img-preview > img") + let req = { + image: task.reqBody.control_image, + filter: task.reqBody.control_filter_to_apply, + model_paths: {}, + filter_params: {}, + } + req["model_paths"][task.reqBody.control_filter_to_apply] = task.reqBody.control_filter_to_apply + SD.filter(req).then( + (result) => { + console.log(result) + controlImagePreview.src = result.output[0] + let controlImageLargePreview = taskEntry.querySelector(".controlnet-img-preview .task-fs-initimage img") + controlImageLargePreview.src = controlImagePreview.src + }, + (error) => console.log("filter error", error) + ) + } + createCollapsibles(taskEntry) let draghandle = taskEntry.querySelector(".drag-handle") @@ -1503,10 +1527,6 @@ function createTask(task) { startY = e.target.closest(".imageTaskContainer").offsetTop }) - if (task.reqBody.init_image !== undefined || task.reqBody.control_image !== undefined) { - createInitImageHover(taskEntry) - } - task["taskStatusLabel"] = taskEntry.querySelector(".taskStatusLabel") task["outputContainer"] = taskEntry.querySelector(".img-preview") task["outputMsg"] = taskEntry.querySelector(".outputMsg")