WIP - parity with square vs non- in/output HRfix res

This commit is contained in:
tim h 2023-01-04 23:27:02 -06:00
parent 898cd35f62
commit b45ce1aeba
3 changed files with 33 additions and 43 deletions

View file

@ -100,28 +100,13 @@
<input type="checkbox" id="cbxHRFix" onchange="changeHiResFix()" />
<label for="cbxHRFix">Apply txt2img HRfix</label>
<br />
<label class="hrfix">Resize to (>0 overrides scale):</label>
<input
type="checkbox"
id="cbxHRFSquare"
onchange="changeHiResSquare()"
class="hrfix" />
<label for="cbxHRFSquare" class="hrfix">Square Aspect</label>
<br class="hrfix" />
<label for="hrfOutX" class="hrfix">X:</label>
<input
type="number"
id="hr_resize_x"
onchange="changeHRFX()"
min="0"
max="2048"
value="0"
step="8"
class="hrfix thirdwidth" />
<label for="hrfOutY" class="hrfix">Y:</label>
<input
type="number"
id="hr_resize_y"
onchange="changeHRFY()"
min="0"
max="2048"
value="0"
step="8"
class="hrfix thirdwidth" />
<div id="hrFixScale" class="hrfix"></div>
<div id="hrFixLockPx" class="hrfix"></div>
<div id="hrFixSteps" class="hrfix"></div>

View file

@ -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) => {

View file

@ -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;
}