From 43d42398243e04fa5d2098beb0cd491423dd6362 Mon Sep 17 00:00:00 2001 From: tim h Date: Mon, 2 Jan 2023 13:50:28 -0600 Subject: [PATCH 01/12] sigh --- index.html | 50 ++++++++++++++++++++------------------ js/index.js | 59 +++++++++++++++++++++++++++++++++------------ js/ui/tool/dream.js | 25 ++++++++++--------- 3 files changed, 83 insertions(+), 51 deletions(-) diff --git a/index.html b/index.html index 853d66d..503a723 100644 --- a/index.html +++ b/index.html @@ -98,9 +98,11 @@ step="1" />
- +
-
+
+ +
+ + +
+ +
+ + - - - -
- -
- - +
@@ -337,7 +339,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 02/12] 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 03/12] 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 04/12] 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 05/12] 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 @@ - + - + - + - + - + - + - +