From 02647217b825650942e0c2b75e2e3d5733ca4e98 Mon Sep 17 00:00:00 2001 From: zero01101 Date: Mon, 2 Jan 2023 07:37:18 +0000 Subject: [PATCH 01/24] Fixed resource hashes --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 523c0f3..853d66d 100644 --- a/index.html +++ b/index.html @@ -337,7 +337,7 @@ - + - + - + diff --git a/js/index.js b/js/index.js index fb68673..23988ad 100644 --- a/js/index.js +++ b/js/index.js @@ -106,8 +106,10 @@ var stableDiffusionData = { inpainting_fill: 2, enable_hr: false, restore_faces: false, - firstphase_width: 0, - firstphase_height: 0, + //firstphase_width: 0, + //firstphase_height: 0, //20230102 welp looks like the entire way HRfix is implemented has become bonkersly different + hr_scale: 2.0, + hr_upscaler: "None", styles: [], // here's some more fields that might be useful @@ -552,6 +554,14 @@ const upscalerAutoComplete = createAutoComplete( document.getElementById("upscaler-ac-select") ); +const hrFixUpscalerAutoComplete = createAutoComplete( + "HRfix Upscaler", + document.getElementById("hrFixUpscaler") +); +hrFixUpscalerAutoComplete.onchange.on(({value}) => { + stableDiffusionData.hr_upscaler = value; +}); + const resSlider = makeSlider( "Resolution", document.getElementById("resolution"), @@ -563,8 +573,6 @@ const resSlider = makeSlider( 2, (v) => { stableDiffusionData.width = stableDiffusionData.height = v; - stableDiffusionData.firstphase_width = - stableDiffusionData.firstphase_height = v / 2; toolbar.currentTool && toolbar.currentTool.redraw && @@ -621,15 +629,16 @@ makeSlider( 1 ); +// 20230102 grumble grumble makeSlider( - "HRfix Lock Px.", - document.getElementById("hrFixLock"), - "hr_fix_lock_px", - 0.0, - 768.0, - 256.0, - 0.0, - 1.0 + "HRfix Scale", + document.getElementById("hrFixScale"), + "hr_scale", + 1.0, + 4.0, + 0.1, + 2.0, + 0.1 ); function changeMaskBlur() { @@ -649,6 +658,20 @@ function changeHiResFix() { document.getElementById("cbxHRFix").checked ); localStorage.setItem("openoutpaint/enable_hr", stableDiffusionData.enable_hr); + var hrfSlider = document.getElementById("hrFixScale"); + var hrfOpotions = document.getElementById("hrFixUpscaler"); + var hrfLabel = document.getElementById("hrFixLabel"); + if (stableDiffusionData.enable_hr) { + hrfSlider.classList.remove("invisible"); + hrfOpotions.classList.remove("invisible"); + hrfLabel.classList.remove("invisible"); + //state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.add("invisible"); + } else { + hrfSlider.classList.add("invisible"); + hrfOpotions.classList.add("invisible"); + hrfLabel.classList.add("invisible"); + //state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.remove("invisible"); + } } function changeRestoreFaces() { @@ -743,17 +766,23 @@ async function getUpscalers() { "[index] purposefully_incorrect_data response, ignore above error" ); // result = purposefully_incorrect_data response: Invalid upscaler, needs to be on of these: None , Lanczos , Nearest , LDSR , BSRGAN , R-ESRGAN General 4xV3 , R-ESRGAN 4x+ Anime6B , ScuNET , ScuNET PSNR , SwinIR_4x - const upscalers = data.detail + const upscalersPlusNone = data.detail .split(": ")[1] .split(",") - .map((v) => v.trim()) - .filter((v) => v !== "None"); // converting the result to a list of upscalers + .map((v) => v.trim()); // need "None" for stupid hrfix changes razza frazza + const upscalers = upscalersPlusNone.filter((v) => v !== "None"); // converting the result to a list of upscalers + upscalersPlusNone.push("Latent"); + upscalersPlusNone.push("Latent (nearest)"); // GRUMBLE GRUMBLE upscalerAutoComplete.options = upscalers.map((u) => { return {name: u, value: u}; }); + hrFixUpscalerAutoComplete.options = upscalersPlusNone.map((u) => { + return {name: u, value: u}; + }); upscalerAutoComplete.value = upscalers[0]; + hrFixUpscalerAutoComplete.value = upscalersPlusNone[0]; } catch (e) { console.warn("[index] Failed to fetch upscalers:"); console.warn(e); diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index f0e1fab..3a3bd53 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -1387,18 +1387,6 @@ const dreamTool = () => h: stableDiffusionData.height, }; - //hacky set non-square auto hrfix values - let hrLockPx = - localStorage.getItem("openoutpaint/hr_fix_lock_px") ?? 0; - stableDiffusionData.firstphase_height = - hrLockPx == 0 || resolution.h / 2 <= hrLockPx - ? resolution.h / 2 - : hrLockPx; - stableDiffusionData.firstphase_width = - hrLockPx == 0 || resolution.w / 2 <= hrLockPx - ? resolution.w / 2 - : hrLockPx; - if (global.connection === "online") { dream_generate_callback(bb, resolution, state); } else { @@ -1492,8 +1480,14 @@ const dreamTool = () => state.ctxmenu.keepUnmaskedBlurSlider.classList.remove( "invisible" ); + state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.add( + "invisible" + ); } else { state.ctxmenu.keepUnmaskedBlurSlider.classList.add("invisible"); + state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.remove( + "invisible" + ); } } ).label; @@ -1511,6 +1505,12 @@ const dreamTool = () => } ).slider; + state.ctxmenu.keepUnmaskedBlurSliderLinebreak = + document.createElement("br"); + state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.add( + "invisible" + ); + // Preserve Brushed Masks Checkbox state.ctxmenu.preserveMasksLabel = _toolbar_input.checkbox( state, @@ -1552,6 +1552,7 @@ const dreamTool = () => menu.appendChild(document.createElement("br")); menu.appendChild(state.ctxmenu.keepUnmaskedLabel); menu.appendChild(state.ctxmenu.keepUnmaskedBlurSlider); + menu.appendChild(state.ctxmenu.keepUnmaskedBlurSliderLinebreak); menu.appendChild(state.ctxmenu.preserveMasksLabel); menu.appendChild(document.createElement("br")); menu.appendChild(state.ctxmenu.overMaskPxLabel); From 8aa0007c2cc205c5c718a5ce2f802f1b74b6a2a0 Mon Sep 17 00:00:00 2001 From: zero01101 Date: Mon, 2 Jan 2023 19:54:27 +0000 Subject: [PATCH 03/24] Fixed resource hashes --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 503a723..976b608 100644 --- a/index.html +++ b/index.html @@ -339,7 +339,7 @@ - + - + From 8962d75c608c19596ff3c335d2a4637d2fe4c0ba Mon Sep 17 00:00:00 2001 From: tim h Date: Mon, 2 Jan 2023 14:49:47 -0600 Subject: [PATCH 04/24] optionally implements dishonesty to POST request data to make new HRfix actually useful to our needs --- index.html | 4 ++-- js/ui/tool/dream.js | 16 ++++++++++++++++ pages/configuration.html | 12 ++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 976b608..789bf7c 100644 --- a/index.html +++ b/index.html @@ -313,7 +313,7 @@
+ src="pages/configuration.html?v=3d710ce"> @@ -353,7 +353,7 @@ src="js/ui/tool/generic.js?v=2bcd36d" type="text/javascript"> - + diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 3a3bd53..53428a1 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -130,6 +130,22 @@ const _dream = async (endpoint, request) => { let data = null; try { generating = true; + if ( + endpoint == "txt2img" && + request.enable_hr && + localStorage.getItem("openoutpaint/settings.hrfix-liar") == "true" + ) { + /** + * try and make the new HRfix method useful for our purposes + * since it now returns an image that's been upscaled x the hr_scale parameter, + * we cheekily lie to SD and tell it that the original dimensions are _divided_ + * by the scale factor so it returns something about the same size as we wanted initially + */ + var newWidth = Math.floor(request.width / request.hr_scale); + var newHeight = Math.floor(request.height / request.hr_scale); + request.width = newWidth; + request.height = newHeight; + } const response = await fetch(apiURL, { method: "POST", headers: { diff --git a/pages/configuration.html b/pages/configuration.html index 2adff2a..81409ec 100644 --- a/pages/configuration.html +++ b/pages/configuration.html @@ -84,6 +84,10 @@ step="0.1" value="30.0" /> +

Refresh the page to apply settings.

From 6e14e3741f4c449649080bb6e7a6ee867f339abd Mon Sep 17 00:00:00 2001 From: zero01101 Date: Mon, 2 Jan 2023 20:50:10 +0000 Subject: [PATCH 05/24] Fixed resource hashes --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 789bf7c..65d1524 100644 --- a/index.html +++ b/index.html @@ -353,7 +353,7 @@ src="js/ui/tool/generic.js?v=2bcd36d" type="text/javascript"> - + From 69205e5647bbb9bf0a507965738dcbf19ea06544 Mon Sep 17 00:00:00 2001 From: tim h Date: Mon, 2 Jan 2023 17:18:50 -0600 Subject: [PATCH 06/24] adds denoising slider for hrfix --- index.html | 5 +++-- js/index.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 65d1524..03da147 100644 --- a/index.html +++ b/index.html @@ -103,6 +103,7 @@
+
- Alpha release v0.0.12.3 + Alpha release v0.0.12.5
@@ -339,7 +340,7 @@ - + - + - + - + - + - + - + diff --git a/pages/configuration.html b/pages/configuration.html index 2adff2a..c2c8dcc 100644 --- a/pages/configuration.html +++ b/pages/configuration.html @@ -5,12 +5,12 @@ openOutpaint 🐠 - + - + From b8c02d630dd3f42b414488e79dc8a4faf8ea6bff Mon Sep 17 00:00:00 2001 From: tim h Date: Mon, 2 Jan 2023 18:29:23 -0600 Subject: [PATCH 12/24] fix selected HRfix upscaler localstorage --- index.html | 2 +- js/index.js | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 06d2251..272c403 100644 --- a/index.html +++ b/index.html @@ -340,7 +340,7 @@ - + - + + @@ -337,7 +337,7 @@ - + diff --git a/js/ui/tool/interrogate.js b/js/ui/tool/interrogate.js index 2090c03..b7fc403 100644 --- a/js/ui/tool/interrogate.js +++ b/js/ui/tool/interrogate.js @@ -97,8 +97,9 @@ const interrogateTool = () => state.ctxmenu.snapToGridLabel = _toolbar_input.checkbox( state, "snapToGrid", - "Snap To Grid" - ).label; + "Snap To Grid", + "icon-grid" + ).checkbox; } menu.appendChild(state.ctxmenu.cursorSizeSlider); From 3f2bbf02ef1d93edd5bcdd5a64c59616dd746950 Mon Sep 17 00:00:00 2001 From: tim h Date: Mon, 2 Jan 2023 21:30:20 -0600 Subject: [PATCH 16/24] checks for nonexistent option in newer webUI on startup --- js/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/index.js b/js/index.js index b22d37b..ab002f0 100644 --- a/js/index.js +++ b/js/index.js @@ -343,6 +343,12 @@ async function testHostConnection() { const response = await fetch( document.getElementById("host").value + "/sdapi/v1/options" ); + const optionsdata = await response.json(); + if (optionsdata["use_scale_latent_for_hires_fix"]) { + const message = `You are using an outdated version of A1111 webUI.\nThe HRfix options will not work until you update to at least commit ef27a18\n(https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/ef27a18b6b7cb1a8eebdc9b2e88d25baf2c2414d)\nor newer.`; + console.error(message); + alert(message); + } switch (response.status) { case 200: { setConnectionStatus("online"); From 0376324666a3cca3500da9026a09e9258cc33f9e Mon Sep 17 00:00:00 2001 From: zero01101 Date: Tue, 3 Jan 2023 03:30:45 +0000 Subject: [PATCH 17/24] Fixed resource hashes --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 89164ba..c9d9462 100644 --- a/index.html +++ b/index.html @@ -340,7 +340,7 @@ - + - + - + From fdd9c8def170ca0d1660f4f8bddf83eb8c51d5f3 Mon Sep 17 00:00:00 2001 From: tim h Date: Mon, 2 Jan 2023 22:15:47 -0600 Subject: [PATCH 19/24] whoops just noticed this, tiny fix --- index.html | 6 +++--- js/ui/tool/dream.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 71067f4..852f7ba 100644 --- a/index.html +++ b/index.html @@ -322,7 +322,7 @@ - + @@ -351,10 +351,10 @@ - + diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 956464d..18e42ad 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -1576,9 +1576,9 @@ const dreamTool = () => array.appendChild(state.ctxmenu.keepUnmaskedLabel); menu.appendChild(array); menu.appendChild(state.ctxmenu.keepUnmaskedBlurSlider); - menu.appendChild(state.ctxmenu.keepUnmaskedBlurSliderLinebreak); - menu.appendChild(state.ctxmenu.preserveMasksLabel); - menu.appendChild(document.createElement("br")); + // menu.appendChild(state.ctxmenu.keepUnmaskedBlurSliderLinebreak); + // menu.appendChild(state.ctxmenu.preserveMasksLabel); + // menu.appendChild(document.createElement("br")); menu.appendChild(state.ctxmenu.overMaskPxLabel); menu.appendChild(state.ctxmenu.eagerGenerateCountLabel); }, From 4de2efa85e37d589445945e6eb2ed1dd4467bdf7 Mon Sep 17 00:00:00 2001 From: zero01101 Date: Tue, 3 Jan 2023 04:16:09 +0000 Subject: [PATCH 20/24] Fixed resource hashes --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 852f7ba..b2bef61 100644 --- a/index.html +++ b/index.html @@ -322,7 +322,7 @@ - + @@ -351,7 +351,7 @@ From 8b4a35d030c395b327b9f9147d37bd5bfc42f469 Mon Sep 17 00:00:00 2001 From: tim h Date: Mon, 2 Jan 2023 23:36:42 -0600 Subject: [PATCH 21/24] tiny critical fixes gotta keep that outpaint mask at 1 --- js/index.js | 6 +++--- js/ui/tool/dream.js | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/js/index.js b/js/index.js index f950f1f..5ac6a77 100644 --- a/js/index.js +++ b/js/index.js @@ -650,7 +650,7 @@ makeSlider( makeSlider( "HRfix Denoising", document.getElementById("hrDenoising"), - "denoising_strength", + "hr_denoising_strength", 0.0, 1.0, 0.05, @@ -1141,9 +1141,9 @@ function loadSettings() { : localStorage.getItem("openoutpaint/hr_scale"); let _hrfix_denoising = - localStorage.getItem("openoutpaint/denoising_strength") === null + localStorage.getItem("openoutpaint/hr_denoising_strength") === null ? 0.7 - : localStorage.getItem("openoutpaint/denoising_strength"); + : localStorage.getItem("openoutpaint/hr_denoising_strength"); // set the values into the UI document.getElementById("maskBlur").value = Number(_mask_blur); document.getElementById("seed").value = Number(_seed); diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 18e42ad..732ea31 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -146,6 +146,9 @@ const _dream = async (endpoint, request) => { request.width = newWidth; request.height = newHeight; } + if (endpoint == "txt2img") { + request.denoising_strength = stableDiffusionData.hr_denoising_strength; + } const response = await fetch(apiURL, { method: "POST", headers: { @@ -2146,7 +2149,7 @@ const img2imgTool = () => array.appendChild(state.ctxmenu.keepUnmaskedLabel); menu.appendChild(array); menu.appendChild(state.ctxmenu.keepUnmaskedBlurSlider); - menu.appendChild(state.ctxmenu.keepUnmaskedBlurSliderLinebreak); + // menu.appendChild(state.ctxmenu.keepUnmaskedBlurSliderLinebreak); menu.appendChild(state.ctxmenu.inpaintTypeSelect); menu.appendChild(state.ctxmenu.denoisingStrengthSlider); const btnArray2 = document.createElement("div"); From 23ad0800557499eae77110d4d6e99752448cad7c Mon Sep 17 00:00:00 2001 From: zero01101 Date: Tue, 3 Jan 2023 05:37:04 +0000 Subject: [PATCH 22/24] Fixed resource hashes --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index b2bef61..3cf1a9a 100644 --- a/index.html +++ b/index.html @@ -340,7 +340,7 @@ - + - + From d31eb541cf63802c6737f44393f1843e5c5db595 Mon Sep 17 00:00:00 2001 From: tim h Date: Tue, 3 Jan 2023 08:16:09 -0600 Subject: [PATCH 23/24] tiny but very vital fix for inpainting --- js/index.js | 2 +- js/ui/tool/dream.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/index.js b/js/index.js index 5ac6a77..dabd70e 100644 --- a/js/index.js +++ b/js/index.js @@ -103,7 +103,7 @@ var stableDiffusionData = { mask: "", init_images: [], inpaint_full_res: false, - inpainting_fill: 2, + inpainting_fill: 1, enable_hr: false, restore_faces: false, //firstphase_width: 0, diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 732ea31..b01cfb5 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -991,7 +991,7 @@ const dream_img2img_callback = (bb, resolution, state) => { request.height = resolution.h; request.denoising_strength = state.denoisingStrength; - request.inpainting_fill = state.inpainting_fill; //let's see how this works //1; // For img2img use original + request.inpainting_fill = state.inpainting_fill ?? 1; //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; From 36fda1e2b52282f127a5e9b11ee6c8873ad47cab Mon Sep 17 00:00:00 2001 From: zero01101 Date: Tue, 3 Jan 2023 14:16:33 +0000 Subject: [PATCH 24/24] Fixed resource hashes --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 3cf1a9a..c6506d3 100644 --- a/index.html +++ b/index.html @@ -340,7 +340,7 @@ - + - +