From f74e7cc180ee2303c6e6d3d1e0641eff5de5d8ff Mon Sep 17 00:00:00 2001 From: zero01101 Date: Thu, 31 Aug 2023 12:55:12 +0000 Subject: [PATCH 01/12] Fixed resource hashes --- index.html | 8 ++++---- pages/configuration.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 42ec558..f101ea2 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ - + @@ -558,7 +558,7 @@ - + - + @@ -592,7 +592,7 @@ src="js/initalize/workspace.populate.js?v=925431d" type="text/javascript"> - + @@ -574,7 +574,7 @@ src="js/ui/tool/generic.js?v=3e678e0" type="text/javascript"> - + diff --git a/js/extensions.js b/js/extensions.js index b4e8448..d80fdcd 100644 --- a/js/extensions.js +++ b/js/extensions.js @@ -53,6 +53,7 @@ const extensions = { console.warn("[index] Failed to fetch extensions"); console.warn(e); } + this.checkForSoftInpainting(); this.checkForDynamicPrompts(); this.checkForControlNet( controlNetModelAutoComplete, @@ -64,6 +65,11 @@ const extensions = { //checkForSAG(); //?? }, + async checkForSoftInpainting() { + this.alwaysOnScripts = true; + //TODO implement, inpaint/img2img only + }, + async checkForDynamicPrompts() { if ( this.enabledExtensions.filter((e) => e.includes("dynamic prompts")) diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 7938e0b..b0a1d01 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -62,12 +62,9 @@ const _monitorProgress = (bb, oncheck = null) => { } const timeSpent = performance.now() - init; - setTimeout( - () => { - if (running) _checkProgress(); - }, - Math.max(0, minDelay - timeSpent) - ); + setTimeout(() => { + if (running) _checkProgress(); + }, Math.max(0, minDelay - timeSpent)); }; _checkProgress(); @@ -1841,8 +1838,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, @@ -1869,8 +1866,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( getBoundingBox( evn.x, @@ -2385,8 +2382,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", @@ -2423,8 +2420,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", @@ -2717,7 +2714,7 @@ const img2imgTool = () => ).slider; // Border Mask Gradient Checkbox - state.ctxmenu.borderMaskGradientCheckbox = _toolbar_input.checkbox( + state.ctxmenu.borderMaskGradientLabel = _toolbar_input.checkbox( state, "openoutpaint/img2img-gradient", "gradient", @@ -2745,6 +2742,152 @@ const img2imgTool = () => } ).checkbox; + // soft inpainting checkbox - arg 0 + state.ctxmenu.softInpaintLabel = _toolbar_input.checkbox( + state, + "openoutpaint/img2img-softinpaint", + "softInpaint", + "Soft Inpainting", + "icon-squircle", + () => { + if (state.softInpaint) { + state.ctxmenu.softInpaintScheduleBiasSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintMaskInfluenceSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceContrastSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceThresholdSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintPreservationStrengthSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintTransitionContrastBoostSlider.classList.remove( + "invisible" + ); + // state.ctxmenu.softInpaintSliderLinebreak.classList.add( + // "invisible" + // ); + } else { + state.ctxmenu.softInpaintScheduleBiasSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintMaskInfluenceSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceContrastSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceThresholdSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintPreservationStrengthSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintTransitionContrastBoostSlider.classList.add( + "invisible" + ); + // state.ctxmenu.softInpaintSliderLinebreak.classList.remove( + // "invisible" + // ); + } + } + ).checkbox; + + // soft inpainting schedule bias - arg 1, def 1 + state.ctxmenu.softInpaintScheduleBiasSlider = _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpaintschedulebias", + "softInpaintScheduleBias", + "Schedule Bias", + { + min: 0, + max: 8, + step: 0.25, + textStep: 0.01, + } + ).slider; + + // soft inpainting preservation strength - arg 2, def 0.5 + state.ctxmenu.softInpaintPreservationStrengthSlider = + _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpaintpreservationstrength", + "softInpaintPreservationStrength", + "Preservation Strength", + { + min: 0, + max: 8, + step: 0.25, + textStep: 0.01, + } + ).slider; + + // soft inpainting transition contrast boost - arg 3, def 4 + state.ctxmenu.softInpaintTransitionContrastBoostSlider = + _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpainttransitioncontrastboost", + "softInpaintTransitionContrastBoost", + "Transition Contrast Boost", + { + min: 0, + max: 32, + step: 0.5, + textStep: 0.01, + } + ).slider; + + //0.5 2 + + // soft inpainting mask influence - arg 4, def 0 + state.ctxmenu.softInpaintMaskInfluenceSlider = _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpaintmaskinfluence", + "softInpaintMaskInfluence", + "Mask Influence", + { + min: 0, + max: 1, + step: 0.1, + textStep: 0.01, + } + ).slider; + + // soft inpainting difference threshold - arg 5, def 0.5 + state.ctxmenu.softInpaintDifferenceThresholdSlider = + _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpaintdifferencethreshold", + "softInpaintDifferenceThreshold", + "Difference Threshold", + { + min: 0, + max: 8, + step: 0.25, + textStep: 0.01, + } + ).slider; + + // soft inpainting difference contrast - arg 6, def 2 + state.ctxmenu.softInpaintDifferenceContrastSlider = + _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpaintdifferenceContrast", + "softInpaintDifferenceContrast", + "Difference Contrast", + { + min: 0, + max: 8, + step: 0.25, + textStep: 0.01, + } + ).slider; + // Border Mask Size Slider state.ctxmenu.borderMaskSlider = _toolbar_input.slider( state, @@ -2858,8 +3001,17 @@ const img2imgTool = () => const btnArray2 = document.createElement("div"); btnArray2.classList.add("checkbox-array"); btnArray2.appendChild(state.ctxmenu.fullResolutionLabel); - btnArray2.appendChild(state.ctxmenu.borderMaskGradientCheckbox); + btnArray2.appendChild(state.ctxmenu.borderMaskGradientLabel); + btnArray2.appendChild(state.ctxmenu.softInpaintLabel); menu.appendChild(btnArray2); + menu.appendChild(state.ctxmenu.softInpaintScheduleBiasSlider); + menu.appendChild(state.ctxmenu.softInpaintPreservationStrengthSlider); + menu.appendChild( + state.ctxmenu.softInpaintTransitionContrastBoostSlider + ); + menu.appendChild(state.ctxmenu.softInpaintMaskInfluenceSlider); + menu.appendChild(state.ctxmenu.softInpaintDifferenceThresholdSlider); + menu.appendChild(state.ctxmenu.softInpaintDifferenceContrastSlider); menu.appendChild(state.ctxmenu.borderMaskSlider); menu.appendChild(state.ctxmenu.eagerGenerateCountLabel); @@ -2878,6 +3030,48 @@ const img2imgTool = () => state.ctxmenu.carveBlurSlider.classList.add("invisible"); state.ctxmenu.carveThresholdSlider.classList.add("invisible"); } + + if ( + localStorage.getItem("openoutpaint/img2img-softinpaint") == "true" + ) { + state.ctxmenu.softInpaintScheduleBiasSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintMaskInfluenceSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceContrastSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceThresholdSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintPreservationStrengthSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintTransitionContrastBoostSlider.classList.remove( + "invisible" + ); + } else { + state.ctxmenu.softInpaintScheduleBiasSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintMaskInfluenceSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceContrastSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceThresholdSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintPreservationStrengthSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintTransitionContrastBoostSlider.classList.add( + "invisible" + ); + } }, shortcut: "I", } diff --git a/pages/configuration.html b/pages/configuration.html index 1a241e4..87e300f 100644 --- a/pages/configuration.html +++ b/pages/configuration.html @@ -5,7 +5,7 @@ openOutpaint 🐠 - + diff --git a/res/icons/squircle.svg b/res/icons/squircle.svg new file mode 100644 index 0000000..8eea9d8 --- /dev/null +++ b/res/icons/squircle.svg @@ -0,0 +1 @@ + \ No newline at end of file From c252ed6ea1f55ae042f2646949a09f044a4b9628 Mon Sep 17 00:00:00 2001 From: tim h Date: Wed, 21 Feb 2024 14:40:02 -0600 Subject: [PATCH 03/12] it works --- index.html | 10 +++++----- js/extensions.js | 1 + js/index.js | 4 ++-- js/ui/tool/dream.js | 26 ++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 6bb6f8a..745c4e2 100644 --- a/index.html +++ b/index.html @@ -186,12 +186,12 @@
- -
+
--> - + @@ -560,7 +560,7 @@ - + - + diff --git a/js/extensions.js b/js/extensions.js index d80fdcd..410e00d 100644 --- a/js/extensions.js +++ b/js/extensions.js @@ -5,6 +5,7 @@ const extensions = { // alwaysOnScriptsData: {}, alwaysOnScripts: false, + // softInpaintingEnabled: false, //??? controlNetEnabled: false, controlNetActive: false, controlNetReferenceActive: false, diff --git a/js/index.js b/js/index.js index c1442d9..b5ccf7a 100644 --- a/js/index.js +++ b/js/index.js @@ -170,7 +170,7 @@ function startup() { changeRefinerEnabled(); changeHiResFix(); changeHiResSquare(); - changeRestoreFaces(); + // changeRestoreFaces(); changeSyncCursorSize(); changeControlNetExtension(); changeControlNetReference(); @@ -1558,7 +1558,7 @@ function loadSettings() { document.getElementById("maskBlur").value = Number(_mask_blur); document.getElementById("seed").value = Number(_seed); document.getElementById("cbxHRFix").checked = Boolean(_enable_hr); - document.getElementById("cbxRestoreFaces").checked = Boolean(_restore_faces); + // document.getElementById("cbxRestoreFaces").checked = Boolean(_restore_faces); document.getElementById("cbxSyncCursorSize").checked = Boolean(_sync_cursor_size); document.getElementById("hrFixScale").value = Number(_hrfix_scale); diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index b0a1d01..85da32c 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -1585,6 +1585,7 @@ const dream_img2img_callback = (bb, resolution, state) => { if (extensions.dynamicPromptsEnabled) { addDynamicPromptsToAlwaysOnScripts(state); } + // and controlnet if (extensions.controlNetActive) { if (extensions.controlNetReferenceActive) { addControlNetToAlwaysOnScripts( @@ -1596,6 +1597,12 @@ const dream_img2img_callback = (bb, resolution, state) => { addControlNetToAlwaysOnScripts(state, null, null); // //WTF??? } } + // and soft inpainting + if (state.softInpaint) { + addSoftInpaintingToAlwaysOnScripts(state); + // TODO build always on scripts entry for soft inpaint + } + if (extensions.alwaysOnScripts) { // check again just to be sure because i'm an idiot? // addControlNetToAlwaysOnScripts(state); @@ -2751,6 +2758,7 @@ const img2imgTool = () => "icon-squircle", () => { if (state.softInpaint) { + extensions.checkForSoftInpainting(); state.ctxmenu.softInpaintScheduleBiasSlider.classList.remove( "invisible" ); @@ -3082,11 +3090,29 @@ const sendSeed = (seed) => { }; function buildAlwaysOnScripts(state) { + //todo make sure soft inpainting works + if (extensions.alwaysOnScripts) { state.alwayson_scripts = {}; } } +function addSoftInpaintingToAlwaysOnScripts(state) { + if (extensions.alwaysOnScripts) { + //????? + state.alwayson_scripts["Soft Inpainting"] = {}; + state.alwayson_scripts["Soft Inpainting"].args = [ + state.softInpaint, + state.softInpaintScheduleBias, + state.softInpaintPreservationStrength, + state.softInpaintTransitionContrastBoost, + state.softInpaintMaskInfluence, + state.softInpaintDifferenceThreshold, + state.softInpaintDifferenceContrast, + ]; + } +} + function addDynamicPromptsToAlwaysOnScripts(state) { if (extensions.dynamicPromptsEnabled) { state.alwayson_scripts[extensions.dynamicPromptsAlwaysonScriptName] = {}; From 51265ff808488dffd4acea22430cc7f8668f9d44 Mon Sep 17 00:00:00 2001 From: tim h Date: Wed, 21 Feb 2024 17:18:36 -0600 Subject: [PATCH 04/12] probably unnecessary --- js/ui/tool/dream.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 85da32c..a93fec9 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -3098,7 +3098,7 @@ function buildAlwaysOnScripts(state) { } function addSoftInpaintingToAlwaysOnScripts(state) { - if (extensions.alwaysOnScripts) { + if (extensions.alwaysOnScripts && toolbar._current_tool.name == "Img2Img") { //????? state.alwayson_scripts["Soft Inpainting"] = {}; state.alwayson_scripts["Soft Inpainting"].args = [ From 1146f2c59398668ae05d262272062585acb90a5e Mon Sep 17 00:00:00 2001 From: zero01101 Date: Wed, 21 Feb 2024 23:19:34 +0000 Subject: [PATCH 05/12] Fixed resource hashes --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 745c4e2..e2613c3 100644 --- a/index.html +++ b/index.html @@ -574,7 +574,7 @@ src="js/ui/tool/generic.js?v=3e678e0" type="text/javascript"> - + From fcf504fb373bf6c05096c875b15b274f8ec41dd3 Mon Sep 17 00:00:00 2001 From: tim h Date: Wed, 21 Feb 2024 17:19:43 -0600 Subject: [PATCH 06/12] whoops --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 745c4e2..e2613c3 100644 --- a/index.html +++ b/index.html @@ -574,7 +574,7 @@ src="js/ui/tool/generic.js?v=3e678e0" type="text/javascript"> - + From 04e2d5ceaf92ccc29b7f52f8343ebcb7837cdbe6 Mon Sep 17 00:00:00 2001 From: zero01101 Date: Wed, 21 Feb 2024 23:20:27 +0000 Subject: [PATCH 07/12] Prettified Code! --- index.html | 2 +- js/ui/tool/dream.js | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index e2613c3..101f750 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index a93fec9..669b4e7 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -62,9 +62,12 @@ const _monitorProgress = (bb, oncheck = null) => { } const timeSpent = performance.now() - init; - setTimeout(() => { - if (running) _checkProgress(); - }, Math.max(0, minDelay - timeSpent)); + setTimeout( + () => { + if (running) _checkProgress(); + }, + Math.max(0, minDelay - timeSpent) + ); }; _checkProgress(); @@ -1845,8 +1848,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, @@ -1873,8 +1876,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( getBoundingBox( evn.x, @@ -2389,8 +2392,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", @@ -2427,8 +2430,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", From a7a25e1beec1e439917e58ad31447e65a9eef1be Mon Sep 17 00:00:00 2001 From: tim h Date: Wed, 21 Feb 2024 22:03:56 -0600 Subject: [PATCH 08/12] adds soft inpainting to dream tool for outpainting, seems to work crappily, maybe just sdxl, maybe doing it wrong --- index.html | 2 +- js/ui/tool/dream.js | 254 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 228 insertions(+), 28 deletions(-) diff --git a/index.html b/index.html index 101f750..5ab3500 100644 --- a/index.html +++ b/index.html @@ -574,7 +574,7 @@ src="js/ui/tool/generic.js?v=3e678e0" type="text/javascript"> - + diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 669b4e7..7e93353 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -62,12 +62,9 @@ const _monitorProgress = (bb, oncheck = null) => { } const timeSpent = performance.now() - init; - setTimeout( - () => { - if (running) _checkProgress(); - }, - Math.max(0, minDelay - timeSpent) - ); + setTimeout(() => { + if (running) _checkProgress(); + }, Math.max(0, minDelay - timeSpent)); }; _checkProgress(); @@ -1227,6 +1224,7 @@ const dream_generate_callback = async (bb, resolution, state) => { if (extensions.dynamicPromptsEnabled) { addDynamicPromptsToAlwaysOnScripts(state); } + // and controlnet stuff if ( extensions.controlNetActive && !isCanvasBlank(0, 0, bb.w, bb.h, visibleCanvas) @@ -1358,10 +1356,15 @@ const dream_generate_callback = async (bb, resolution, state) => { // add dynamic prompts stuff if it's enabled if (extensions.dynamicPromptsEnabled) { addDynamicPromptsToAlwaysOnScripts(state); - } + } // and controlnet stuff if (extensions.controlNetActive) { addControlNetToAlwaysOnScripts(state, initCanvas, maskCanvas); } + // and soft inpainting + if (state.softInpaint) { + addSoftInpaintingToAlwaysOnScripts(state); + // TODO build always on scripts entry for soft inpaint + } if (extensions.alwaysOnScripts) { // check again just to be sure because i'm an idiot? // addControlNetToAlwaysOnScripts(state); @@ -1848,8 +1851,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, @@ -1876,8 +1879,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( getBoundingBox( evn.x, @@ -2167,6 +2170,153 @@ const dreamTool = () => state.ctxmenu.carveThresholdSlider.classList.add("invisible"); } + // soft inpainting checkbox - arg 0 + state.ctxmenu.softInpaintLabel = _toolbar_input.checkbox( + state, + "openoutpaint/img2img-softinpaint", + "softInpaint", + "Soft Inpainting", + "icon-squircle", + () => { + if (state.softInpaint) { + extensions.checkForSoftInpainting(); + state.ctxmenu.softInpaintScheduleBiasSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintMaskInfluenceSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceContrastSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceThresholdSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintPreservationStrengthSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintTransitionContrastBoostSlider.classList.remove( + "invisible" + ); + // state.ctxmenu.softInpaintSliderLinebreak.classList.add( + // "invisible" + // ); + } else { + state.ctxmenu.softInpaintScheduleBiasSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintMaskInfluenceSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceContrastSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceThresholdSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintPreservationStrengthSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintTransitionContrastBoostSlider.classList.add( + "invisible" + ); + // state.ctxmenu.softInpaintSliderLinebreak.classList.remove( + // "invisible" + // ); + } + } + ).checkbox; + + // soft inpainting schedule bias - arg 1, def 1 + state.ctxmenu.softInpaintScheduleBiasSlider = _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpaintschedulebias", + "softInpaintScheduleBias", + "Schedule Bias", + { + min: 0, + max: 8, + step: 0.25, + textStep: 0.01, + } + ).slider; + + // soft inpainting preservation strength - arg 2, def 0.5 + state.ctxmenu.softInpaintPreservationStrengthSlider = + _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpaintpreservationstrength", + "softInpaintPreservationStrength", + "Preservation Strength", + { + min: 0, + max: 8, + step: 0.25, + textStep: 0.01, + } + ).slider; + + // soft inpainting transition contrast boost - arg 3, def 4 + state.ctxmenu.softInpaintTransitionContrastBoostSlider = + _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpainttransitioncontrastboost", + "softInpaintTransitionContrastBoost", + "Transition Contrast Boost", + { + min: 0, + max: 32, + step: 0.5, + textStep: 0.01, + } + ).slider; + + //0.5 2 + + // soft inpainting mask influence - arg 4, def 0 + state.ctxmenu.softInpaintMaskInfluenceSlider = _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpaintmaskinfluence", + "softInpaintMaskInfluence", + "Mask Influence", + { + min: 0, + max: 1, + step: 0.1, + textStep: 0.01, + } + ).slider; + + // soft inpainting difference threshold - arg 5, def 0.5 + state.ctxmenu.softInpaintDifferenceThresholdSlider = + _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpaintdifferencethreshold", + "softInpaintDifferenceThreshold", + "Difference Threshold", + { + min: 0, + max: 8, + step: 0.25, + textStep: 0.01, + } + ).slider; + + // soft inpainting difference contrast - arg 6, def 2 + state.ctxmenu.softInpaintDifferenceContrastSlider = + _toolbar_input.slider( + state, + "openoutpaint/img2img-softinpaintdifferenceContrast", + "softInpaintDifferenceContrast", + "Difference Contrast", + { + min: 0, + max: 8, + step: 0.25, + textStep: 0.01, + } + ).slider; + menu.appendChild(state.ctxmenu.cursorSizeSlider); const array = document.createElement("div"); array.classList.add("checkbox-array"); @@ -2177,6 +2327,7 @@ const dreamTool = () => //menu.appendChild(document.createElement("br")); array.appendChild(state.ctxmenu.keepUnmaskedLabel); array.appendChild(state.ctxmenu.removeBackgroundLabel); + array.appendChild(state.ctxmenu.softInpaintLabel); //TODO: if (global.controlnetAPI) { //but figure out how to update the UI after doing so // never mind i think i'm using an extension menu instead // array.appendChild(state.ctxmenu.controlNetLabel); @@ -2185,6 +2336,14 @@ const dreamTool = () => menu.appendChild(state.ctxmenu.keepUnmaskedBlurSlider); menu.appendChild(state.ctxmenu.carveBlurSlider); menu.appendChild(state.ctxmenu.carveThresholdSlider); + menu.appendChild(state.ctxmenu.softInpaintScheduleBiasSlider); + menu.appendChild(state.ctxmenu.softInpaintPreservationStrengthSlider); + menu.appendChild( + state.ctxmenu.softInpaintTransitionContrastBoostSlider + ); + menu.appendChild(state.ctxmenu.softInpaintMaskInfluenceSlider); + menu.appendChild(state.ctxmenu.softInpaintDifferenceThresholdSlider); + menu.appendChild(state.ctxmenu.softInpaintDifferenceContrastSlider); // menu.appendChild(state.ctxmenu.keepUnmaskedBlurSliderLinebreak); // menu.appendChild(state.ctxmenu.preserveMasksLabel); // menu.appendChild(document.createElement("br")); @@ -2205,6 +2364,48 @@ const dreamTool = () => state.ctxmenu.carveBlurSlider.classList.add("invisible"); state.ctxmenu.carveThresholdSlider.classList.add("invisible"); } + + if ( + localStorage.getItem("openoutpaint/img2img-softinpaint") == "true" + ) { + state.ctxmenu.softInpaintScheduleBiasSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintMaskInfluenceSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceContrastSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceThresholdSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintPreservationStrengthSlider.classList.remove( + "invisible" + ); + state.ctxmenu.softInpaintTransitionContrastBoostSlider.classList.remove( + "invisible" + ); + } else { + state.ctxmenu.softInpaintScheduleBiasSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintMaskInfluenceSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceContrastSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintDifferenceThresholdSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintPreservationStrengthSlider.classList.add( + "invisible" + ); + state.ctxmenu.softInpaintTransitionContrastBoostSlider.classList.add( + "invisible" + ); + } }, shortcut: "D", } @@ -2392,8 +2593,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", @@ -2430,8 +2631,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", @@ -3001,20 +3202,11 @@ const img2imgTool = () => array.appendChild(state.ctxmenu.preserveMasksLabel); array.appendChild(state.ctxmenu.keepUnmaskedLabel); array.appendChild(state.ctxmenu.removeBackgroundLabel); + array.appendChild(state.ctxmenu.softInpaintLabel); menu.appendChild(array); menu.appendChild(state.ctxmenu.keepUnmaskedBlurSlider); menu.appendChild(state.ctxmenu.carveBlurSlider); menu.appendChild(state.ctxmenu.carveThresholdSlider); - // menu.appendChild(state.ctxmenu.keepUnmaskedBlurSliderLinebreak); - menu.appendChild(state.ctxmenu.inpaintTypeSelect); - menu.appendChild(state.ctxmenu.denoisingStrengthSlider); - menu.appendChild(state.ctxmenu.instructPix2PixImgCfgLabel); - const btnArray2 = document.createElement("div"); - btnArray2.classList.add("checkbox-array"); - btnArray2.appendChild(state.ctxmenu.fullResolutionLabel); - btnArray2.appendChild(state.ctxmenu.borderMaskGradientLabel); - btnArray2.appendChild(state.ctxmenu.softInpaintLabel); - menu.appendChild(btnArray2); menu.appendChild(state.ctxmenu.softInpaintScheduleBiasSlider); menu.appendChild(state.ctxmenu.softInpaintPreservationStrengthSlider); menu.appendChild( @@ -3023,6 +3215,15 @@ const img2imgTool = () => menu.appendChild(state.ctxmenu.softInpaintMaskInfluenceSlider); menu.appendChild(state.ctxmenu.softInpaintDifferenceThresholdSlider); menu.appendChild(state.ctxmenu.softInpaintDifferenceContrastSlider); + // menu.appendChild(state.ctxmenu.keepUnmaskedBlurSliderLinebreak); + menu.appendChild(state.ctxmenu.inpaintTypeSelect); + menu.appendChild(state.ctxmenu.denoisingStrengthSlider); + menu.appendChild(state.ctxmenu.instructPix2PixImgCfgLabel); + const btnArray2 = document.createElement("div"); + btnArray2.classList.add("checkbox-array"); + btnArray2.appendChild(state.ctxmenu.fullResolutionLabel); + btnArray2.appendChild(state.ctxmenu.borderMaskGradientLabel); + menu.appendChild(btnArray2); menu.appendChild(state.ctxmenu.borderMaskSlider); menu.appendChild(state.ctxmenu.eagerGenerateCountLabel); @@ -3101,8 +3302,7 @@ function buildAlwaysOnScripts(state) { } function addSoftInpaintingToAlwaysOnScripts(state) { - if (extensions.alwaysOnScripts && toolbar._current_tool.name == "Img2Img") { - //????? + if (extensions.alwaysOnScripts) { state.alwayson_scripts["Soft Inpainting"] = {}; state.alwayson_scripts["Soft Inpainting"].args = [ state.softInpaint, From 9040f37849e4d32a1c09b55a4716bce2a1b8a3c2 Mon Sep 17 00:00:00 2001 From: zero01101 Date: Thu, 22 Feb 2024 04:04:11 +0000 Subject: [PATCH 09/12] Prettified Code! --- js/ui/tool/dream.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 7e93353..107847f 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -62,9 +62,12 @@ const _monitorProgress = (bb, oncheck = null) => { } const timeSpent = performance.now() - init; - setTimeout(() => { - if (running) _checkProgress(); - }, Math.max(0, minDelay - timeSpent)); + setTimeout( + () => { + if (running) _checkProgress(); + }, + Math.max(0, minDelay - timeSpent) + ); }; _checkProgress(); @@ -1851,8 +1854,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, @@ -1879,8 +1882,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( getBoundingBox( evn.x, @@ -2593,8 +2596,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", @@ -2631,8 +2634,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", From e720f4dd8f09773ccd7bfea7b8a6c2909a0fb0c0 Mon Sep 17 00:00:00 2001 From: tim h Date: Sat, 2 Mar 2024 07:19:42 -0600 Subject: [PATCH 10/12] version bump for webUI 1.8.0, remove soft inpainting from dream tool, prettier infighting forever --- index.html | 6 +++--- js/ui/tool/dream.js | 43 ++++++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/index.html b/index.html index 5ab3500..c0b22c6 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + @@ -337,7 +337,7 @@
- v202402-03xx.00x TODO CHANGEME + v20240302.001
- + diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 107847f..35e5df3 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -62,12 +62,9 @@ const _monitorProgress = (bb, oncheck = null) => { } const timeSpent = performance.now() - init; - setTimeout( - () => { - if (running) _checkProgress(); - }, - Math.max(0, minDelay - timeSpent) - ); + setTimeout(() => { + if (running) _checkProgress(); + }, Math.max(0, minDelay - timeSpent)); }; _checkProgress(); @@ -1854,8 +1851,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, @@ -1882,8 +1879,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( getBoundingBox( evn.x, @@ -2330,7 +2327,7 @@ const dreamTool = () => //menu.appendChild(document.createElement("br")); array.appendChild(state.ctxmenu.keepUnmaskedLabel); array.appendChild(state.ctxmenu.removeBackgroundLabel); - array.appendChild(state.ctxmenu.softInpaintLabel); + // array.appendChild(state.ctxmenu.softInpaintLabel); //TODO: if (global.controlnetAPI) { //but figure out how to update the UI after doing so // never mind i think i'm using an extension menu instead // array.appendChild(state.ctxmenu.controlNetLabel); @@ -2339,14 +2336,14 @@ const dreamTool = () => menu.appendChild(state.ctxmenu.keepUnmaskedBlurSlider); menu.appendChild(state.ctxmenu.carveBlurSlider); menu.appendChild(state.ctxmenu.carveThresholdSlider); - menu.appendChild(state.ctxmenu.softInpaintScheduleBiasSlider); - menu.appendChild(state.ctxmenu.softInpaintPreservationStrengthSlider); - menu.appendChild( - state.ctxmenu.softInpaintTransitionContrastBoostSlider - ); - menu.appendChild(state.ctxmenu.softInpaintMaskInfluenceSlider); - menu.appendChild(state.ctxmenu.softInpaintDifferenceThresholdSlider); - menu.appendChild(state.ctxmenu.softInpaintDifferenceContrastSlider); + // menu.appendChild(state.ctxmenu.softInpaintScheduleBiasSlider); + // menu.appendChild(state.ctxmenu.softInpaintPreservationStrengthSlider); + // menu.appendChild( + // state.ctxmenu.softInpaintTransitionContrastBoostSlider + // ); + // menu.appendChild(state.ctxmenu.softInpaintMaskInfluenceSlider); + // menu.appendChild(state.ctxmenu.softInpaintDifferenceThresholdSlider); + // menu.appendChild(state.ctxmenu.softInpaintDifferenceContrastSlider); // menu.appendChild(state.ctxmenu.keepUnmaskedBlurSliderLinebreak); // menu.appendChild(state.ctxmenu.preserveMasksLabel); // menu.appendChild(document.createElement("br")); @@ -2596,8 +2593,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", @@ -2634,8 +2631,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", From 882c1ff9fc4f7532b843c66160404f8f75370fc1 Mon Sep 17 00:00:00 2001 From: zero01101 Date: Sat, 2 Mar 2024 13:19:58 +0000 Subject: [PATCH 11/12] Prettified Code! --- index.html | 2 +- js/ui/tool/dream.js | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index c0b22c6..ab23d35 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 35e5df3..5d23d73 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -62,9 +62,12 @@ const _monitorProgress = (bb, oncheck = null) => { } const timeSpent = performance.now() - init; - setTimeout(() => { - if (running) _checkProgress(); - }, Math.max(0, minDelay - timeSpent)); + setTimeout( + () => { + if (running) _checkProgress(); + }, + Math.max(0, minDelay - timeSpent) + ); }; _checkProgress(); @@ -1851,8 +1854,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, @@ -1879,8 +1882,8 @@ const dreamTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( getBoundingBox( evn.x, @@ -2593,8 +2596,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", @@ -2631,8 +2634,8 @@ const img2imgTool = () => state.cursorSize > stableDiffusionData.width ? "#FBB5" : state.cursorSize < stableDiffusionData.width - ? "#BFB5" - : "#FFF5"; + ? "#BFB5" + : "#FFF5"; state.erasePrevReticle = _tool._reticle_draw( bb, "Img2Img", From 5236ab76afb2eab4b400ed8a693421cf51285eba Mon Sep 17 00:00:00 2001 From: zero01101 Date: Sat, 2 Mar 2024 13:20:22 +0000 Subject: [PATCH 12/12] Fixed resource hashes --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index ab23d35..94ef95e 100644 --- a/index.html +++ b/index.html @@ -574,7 +574,7 @@ src="js/ui/tool/generic.js?v=3e678e0" type="text/javascript"> - +