From 227c7839f3137b2eae0b9f3d10718007fc565dcd Mon Sep 17 00:00:00 2001 From: tim h Date: Tue, 3 Jan 2023 21:41:03 -0600 Subject: [PATCH] return of HRfix lock px not sure if useful or i'm just salty --- index.html | 9 +++++---- js/index.js | 22 +++++++++++++++++++++- js/ui/tool/dream.js | 16 ++++++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 1cda974..e644802 100644 --- a/index.html +++ b/index.html @@ -101,6 +101,7 @@
+
@@ -322,7 +323,7 @@ - + @@ -340,7 +341,7 @@ - + - + diff --git a/js/index.js b/js/index.js index d9ac3a2..a2a7ae8 100644 --- a/js/index.js +++ b/js/index.js @@ -642,7 +642,7 @@ makeSlider( ); // 20230102 grumble grumble -makeSlider( +const hrFixScaleSlider = makeSlider( "HRfix Scale", document.getElementById("hrFixScale"), "hr_scale", @@ -664,6 +664,17 @@ makeSlider( 0.01 ); +const lockPxSlider = makeSlider( + "HRfix Autoscale Lock Px.", + document.getElementById("hrFixLockPx"), + "hr_fix_lock_px", + 0, + 1024, + 256, + 0, + 1 +); + function changeMaskBlur() { stableDiffusionData.mask_blur = parseInt( document.getElementById("maskBlur").value @@ -685,17 +696,20 @@ function changeHiResFix() { var hrfOpotions = document.getElementById("hrFixUpscaler"); var hrfLabel = document.getElementById("hrFixLabel"); var hrfDenoiseSlider = document.getElementById("hrDenoising"); + var hrfLockPxSlider = document.getElementById("hrFixLockPx"); if (stableDiffusionData.enable_hr) { hrfSlider.classList.remove("invisible"); hrfOpotions.classList.remove("invisible"); hrfLabel.classList.remove("invisible"); hrfDenoiseSlider.classList.remove("invisible"); + hrfLockPxSlider.classList.remove("invisible"); //state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.add("invisible"); } else { hrfSlider.classList.add("invisible"); hrfOpotions.classList.add("invisible"); hrfLabel.classList.add("invisible"); hrfDenoiseSlider.classList.add("invisible"); + hrfLockPxSlider.classList.add("invisible"); //state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.remove("invisible"); } } @@ -1150,6 +1164,11 @@ function loadSettings() { localStorage.getItem("openoutpaint/hr_denoising_strength") === null ? 0.7 : localStorage.getItem("openoutpaint/hr_denoising_strength"); + let _hrfix_lock_px = + localStorage.getItem("openoutpaint/hr_fix_lock_px") === null + ? 0 + : localStorage.getItem("openoutpaint/hr_fix_lock_px"); + // set the values into the UI document.getElementById("maskBlur").value = Number(_mask_blur); document.getElementById("seed").value = Number(_seed); @@ -1159,6 +1178,7 @@ function loadSettings() { Boolean(_sync_cursor_size); document.getElementById("hrFixScale").value = Number(_hrfix_scale); document.getElementById("hrDenoising").value = Number(_hrfix_denoising); + document.getElementById("hrFixLockPx").value = Number(_hrfix_lock_px); } imageCollection.element.addEventListener( diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 505fb2c..9792b3e 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -141,6 +141,22 @@ const _dream = async (endpoint, request) => { * 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 */ + + // ok so instead, only do that if stableDiffusionData.hr_fix_lock_px > 0 + if (stableDiffusionData.hr_fix_lock_px > 0) { + // find the appropriate scale factor for hrfix + var widthFactor = + request.width / stableDiffusionData.hr_fix_lock_px <= 4 + ? request.width / stableDiffusionData.hr_fix_lock_px + : 4; + var heightFactor = + request.height / stableDiffusionData.hr_fix_lock_px <= 4 + ? request.height / stableDiffusionData.hr_fix_lock_px + : 4; + var factor = heightFactor > widthFactor ? heightFactor : widthFactor; + request.hr_scale = hrFixScaleSlider.value = factor < 1 ? 1 : factor; + } + var newWidth = Math.floor(request.width / request.hr_scale); var newHeight = Math.floor(request.height / request.hr_scale); request.width = newWidth;