From b45ce1aeba12e229361ac85d41cd0848d811c608 Mon Sep 17 00:00:00 2001 From: tim h Date: Wed, 4 Jan 2023 23:27:02 -0600 Subject: [PATCH] WIP - parity with square vs non- in/output HRfix res --- index.html | 27 ++++++--------------------- js/index.js | 29 +++++++++++++++++------------ js/ui/tool/dream.js | 20 ++++++++++---------- 3 files changed, 33 insertions(+), 43 deletions(-) diff --git a/index.html b/index.html index da484f3..ec2c965 100644 --- a/index.html +++ b/index.html @@ -100,28 +100,13 @@
- + +
- - - -
diff --git a/js/index.js b/js/index.js index 8b2ea19..5942bd3 100644 --- a/js/index.js +++ b/js/index.js @@ -114,6 +114,7 @@ var stableDiffusionData = { hr_second_pass_steps: 0, hr_resize_x: 0, hr_resize_y: 0, + hr_square_aspect: false, styles: [], // here's some more fields that might be useful @@ -729,25 +730,19 @@ function changeHiResFix() { document .querySelectorAll(".hrfix") .forEach((el) => el.classList.remove("invisible")); - // 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 { document .querySelectorAll(".hrfix") .forEach((el) => el.classList.add("invisible")); - // 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"); } } +function changeHiResSquare() { + stableDiffusionData.hr_square_aspect = Boolean( + document.getElementById("cbxHRFSquare").checked + ); +} + function changeRestoreFaces() { stableDiffusionData.restore_faces = Boolean( document.getElementById("cbxRestoreFaces").checked @@ -845,7 +840,17 @@ async function getUpscalers() { .split(",") .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", + // "Latent (antialiased)", + // "Latent (bicubic)", + // "Latent (bicubic, antialiased)", + // "Latent (nearest)", + // ]); upscalersPlusNone.push("Latent"); + upscalersPlusNone.push("Latent (antialiased)"); + upscalersPlusNone.push("Latent (bicubic)"); + upscalersPlusNone.push("Latent (bicubic, antialiased)"); upscalersPlusNone.push("Latent (nearest)"); // GRUMBLE GRUMBLE upscalerAutoComplete.options = upscalers.map((u) => { diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 2d5cc58..9ef6706 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -844,20 +844,20 @@ const dream_generate_callback = async (bb, resolution, state) => { var newWidth = Math.floor(request.width / request.hr_scale); var newHeight = Math.floor(request.height / request.hr_scale); - request.hr_resize_x = stableDiffusionData.hr_resize_x; - request.hr_resize_y = stableDiffusionData.hr_resize_y; - request.width = - stableDiffusionData.hr_resize_x || stableDiffusionData.hr_resize_y > 0 - ? request.width - : newWidth; - request.height = - stableDiffusionData.hr_resize_x || stableDiffusionData.hr_resize_y > 0 - ? request.height - : newHeight; //in webUI if _either_ x or y is > 0 then their values are used over scale as per https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/81490780949fffed77493b4bd741e96ec737fe27#diff-ddc07d50fa3b043925b1e831b1373976798d62c9f5c11fcb16c6c830bd3857cdR104 + if (stableDiffusionData.hr_square_aspect) { + larger = newWidth > newHeight ? newWidth : newHeight; + newWidth = larger; + newHeight = larger; + } + request.hr_resize_x = request.width; + request.hr_resize_y = request.height; // screw the scale, damn the man, setting specified output dimensions overrides it anyway, who needs the thing, i need to revisit like all the hrfix code now though because i don't know if NOT lying to it is even worthwhile anymore + request.width = newWidth; + request.height = newHeight; } // For compatibility with the old HRFix API if (global.isOldHRFix && request.enable_hr) { + // For compatibility with the old HRFix API request.firstphase_width = request.width / 2; request.firstphase_height = request.height / 2; }