diff --git a/css/index.css b/css/index.css index 80fa23d..0585f43 100644 --- a/css/index.css +++ b/css/index.css @@ -644,3 +644,9 @@ select > .style-select-option:active { .button.tool.active { background-color: rgb(60, 60, 130); } + +/* Miscellaneous garbage */ + +.thirdwidth { + max-width: 33%; +} diff --git a/index.html b/index.html index ce50bf7..7d6ae00 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ - + @@ -98,10 +98,20 @@ step="1" />
- +
+ + +
+
@@ -341,7 +351,7 @@ - + - + diff --git a/js/index.js b/js/index.js index 1424164..7f341d4 100644 --- a/js/index.js +++ b/js/index.js @@ -111,6 +111,10 @@ var stableDiffusionData = { //firstphase_height: 0, //20230102 welp looks like the entire way HRfix is implemented has become bonkersly different hr_scale: 2.0, hr_upscaler: "None", + 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 @@ -161,6 +165,7 @@ function startup() { changeSmoothRendering(); changeSeed(); changeHiResFix(); + changeHiResSquare(); changeRestoreFaces(); changeSyncCursorSize(); } @@ -679,6 +684,17 @@ const lockPxSlider = makeSlider( 1 ); +const hrStepsSlider = makeSlider( + "HRfix Steps", + document.getElementById("hrFixSteps"), + "hr_second_pass_steps", + 0, + localStorage.getItem("openoutpaint/settings.max-steps") || 70, + 5, + 0, + 1 +); + function changeMaskBlur() { stableDiffusionData.mask_blur = parseInt( document.getElementById("maskBlur").value @@ -691,33 +707,43 @@ function changeSeed() { localStorage.setItem("openoutpaint/seed", stableDiffusionData.seed); } +function changeHRFX() { + stableDiffusionData.hr_resize_x = + document.getElementById("hr_resize_x").value; +} + +function changeHRFY() { + stableDiffusionData.hr_resize_y = + document.getElementById("hr_resize_y").value; +} + function changeHiResFix() { stableDiffusionData.enable_hr = Boolean( 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"); - var hrfDenoiseSlider = document.getElementById("hrDenoising"); - var hrfLockPxSlider = document.getElementById("hrFixLockPx"); + // var hrfSlider = document.getElementById("hrFixScale"); + // 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"); + document + .querySelectorAll(".hrfix") + .forEach((el) => el.classList.remove("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"); + document + .querySelectorAll(".hrfix") + .forEach((el) => el.classList.add("invisible")); } } +function changeHiResSquare() { + stableDiffusionData.hr_square_aspect = Boolean( + document.getElementById("cbxHRFSquare").checked + ); +} + function changeRestoreFaces() { stableDiffusionData.restore_faces = Boolean( document.getElementById("cbxRestoreFaces").checked @@ -815,7 +841,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 77207c5..7760de4 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -156,6 +156,7 @@ const _dream = async (endpoint, request) => { generating(false); } var responseSubdata = JSON.parse(data.info); + console.debug(responseSubdata); var returnData = { images: data.images, seeds: responseSubdata.all_seeds, @@ -815,41 +816,64 @@ const dream_generate_callback = async (bb, resolution, state) => { // Use txt2img if canvas is blank if (isCanvasBlank(0, 0, bb.w, bb.h, visibleCanvas)) { - if ( - !global.isOldHRFix && - request.enable_hr && - localStorage.getItem("openoutpaint/settings.hrfix-liar") == "true" - ) { + if (!global.isOldHRFix && request.enable_hr) { /** * 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 */ - - // 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 + // laziness convenience + let lockpx = stableDiffusionData.hr_fix_lock_px; + if (lockpx > 0) { + // find the most appropriate scale factor for hrfix var widthFactor = - request.width / stableDiffusionData.hr_fix_lock_px <= 4 - ? request.width / stableDiffusionData.hr_fix_lock_px - : 4; + request.width / lockpx <= 4 ? request.width / lockpx : 4; var heightFactor = - request.height / stableDiffusionData.hr_fix_lock_px <= 4 - ? request.height / stableDiffusionData.hr_fix_lock_px - : 4; + request.height / lockpx <= 4 ? request.height / lockpx : 4; var factor = heightFactor > widthFactor ? heightFactor : widthFactor; request.hr_scale = hrFixScaleSlider.value = factor < 1 ? 1 : factor; } + // moar laziness convenience + var divW = Math.floor(request.width / request.hr_scale); + var divH = Math.floor(request.height / request.hr_scale); - var newWidth = Math.floor(request.width / request.hr_scale); - var newHeight = Math.floor(request.height / request.hr_scale); - request.width = newWidth; - request.height = newHeight; + if (localStorage.getItem("openoutpaint/settings.hrfix-liar") == "true") { + /** + * 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 firstpassWidth = divW; + var firstpassHeight = divH; // liar's firstpass output resolution + var desiredWidth = request.width; + var desiredHeight = request.height; // truthful desired output resolution + } else { + // use scale normally, dump supersampled image into undersized reticle + var desiredWidth = request.width * request.hr_scale; + var desiredHeight = request.height * request.hr_scale; //desired 2nd-pass output resolution + var firstpassWidth = request.width; + var firstpassHeight = request.height; + } + + // ensure firstpass "resolution" complies with lockpx + if (lockpx > 0) { + //sigh repeated loop + firstpassWidth = divW < lockpx ? divW : lockpx; + firstpassHeight = divH < lockpx ? divH : lockpx; + } + + if (stableDiffusionData.hr_square_aspect) { + larger = + firstpassWidth > firstpassHeight ? firstpassWidth : firstpassHeight; + firstpassWidth = firstpassHeight = larger; + } + request.width = firstpassWidth; + request.height = firstpassHeight; + request.hr_resize_x = desiredWidth; + request.hr_resize_y = desiredHeight; } // 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; } diff --git a/pages/configuration.html b/pages/configuration.html index 5e53994..ac40172 100644 --- a/pages/configuration.html +++ b/pages/configuration.html @@ -7,7 +7,7 @@ - + @@ -84,11 +84,12 @@ step="0.1" value="30.0" /> + +
-

Refresh the page to apply settings.