From 370994a5d2300c628a2815cf980ca74743b357d6 Mon Sep 17 00:00:00 2001 From: tim h Date: Sat, 31 Dec 2022 13:31:31 -0600 Subject: [PATCH] extremely ugly WIP implementation of img2img inpaint fill modes --- index.html | 4 ++-- js/lib/toolbar.js | 26 ++++++++++++++++++++++++++ js/ui/tool/dream.js | 20 +++++++++++++++++++- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 0ec2607..b1bfe49 100644 --- a/index.html +++ b/index.html @@ -323,7 +323,7 @@ - + - + diff --git a/js/lib/toolbar.js b/js/lib/toolbar.js index d8cad9b..70ee985 100644 --- a/js/lib/toolbar.js +++ b/js/lib/toolbar.js @@ -188,4 +188,30 @@ const _toolbar_input = { }, }; }, + + selectlist: ( + state, + dataKey, + text, + options = {value, text}, + defaultOptionValue, + cb = null + ) => { + const selectlist = document.createElement("select"); + Object.entries(options).forEach((opt) => { + var option = document.createElement("option"); + option.value = opt[0]; + option.text = opt[1]; + selectlist.options.add(option); + }); + selectlist.selectedIndex = defaultOptionValue; + selectlist.onchange = () => { + state[dataKey] = selectlist.selectedIndex; + cb && cb(); + }; + const label = document.createElement("label"); + label.appendChild(selectlist); + label.appendChild(new Text(text)); + return {selectlist, label}; + }, }; diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 5ae2ef3..c09f2c8 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -932,7 +932,7 @@ const dream_img2img_callback = (bb, resolution, state) => { request.height = resolution.h; request.denoising_strength = state.denoisingStrength; - request.inpainting_fill = 1; // For img2img use original + request.inpainting_fill = state.inpainting_fill; //let's see how this works //1; // For img2img use original // Load prompt (maybe we should add some events so we don't have to do this) request.prompt = document.getElementById("prompt").value; @@ -2018,6 +2018,23 @@ const img2imgTool = () => textStep: 1, } ).slider; + + // inpaint fill type select list + state.ctxmenu.inpaintTypeSelect = _toolbar_input.selectlist( + state, + "inpainting_fill", + "Inpaint Type", + { + 0: "fill", + 1: "original (recommended)", + 2: "latent noise", + 3: "latent nothing", + }, + 1, // USE ORIGINAL FOR IMG2IMG OR ELSE but we still give you the option because we love you + () => { + stableDiffusionData.inpainting_fill = state.inpainting_fill; + } + ).label; } menu.appendChild(state.ctxmenu.cursorSizeSlider); @@ -2035,6 +2052,7 @@ const img2imgTool = () => menu.appendChild(state.ctxmenu.denoisingStrengthSlider); menu.appendChild(state.ctxmenu.borderMaskGradientCheckbox); menu.appendChild(state.ctxmenu.borderMaskSlider); + menu.appendChild(state.ctxmenu.inpaintTypeSelect); }, shortcut: "I", }