WIP - parity with square vs non- in/output HRfix res
This commit is contained in:
parent
898cd35f62
commit
b45ce1aeba
3 changed files with 33 additions and 43 deletions
27
index.html
27
index.html
|
@ -100,28 +100,13 @@
|
||||||
<input type="checkbox" id="cbxHRFix" onchange="changeHiResFix()" />
|
<input type="checkbox" id="cbxHRFix" onchange="changeHiResFix()" />
|
||||||
<label for="cbxHRFix">Apply txt2img HRfix</label>
|
<label for="cbxHRFix">Apply txt2img HRfix</label>
|
||||||
<br />
|
<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" />
|
<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="hrFixScale" class="hrfix"></div>
|
||||||
<div id="hrFixLockPx" class="hrfix"></div>
|
<div id="hrFixLockPx" class="hrfix"></div>
|
||||||
<div id="hrFixSteps" class="hrfix"></div>
|
<div id="hrFixSteps" class="hrfix"></div>
|
||||||
|
|
29
js/index.js
29
js/index.js
|
@ -114,6 +114,7 @@ var stableDiffusionData = {
|
||||||
hr_second_pass_steps: 0,
|
hr_second_pass_steps: 0,
|
||||||
hr_resize_x: 0,
|
hr_resize_x: 0,
|
||||||
hr_resize_y: 0,
|
hr_resize_y: 0,
|
||||||
|
hr_square_aspect: false,
|
||||||
styles: [],
|
styles: [],
|
||||||
// here's some more fields that might be useful
|
// here's some more fields that might be useful
|
||||||
|
|
||||||
|
@ -729,25 +730,19 @@ function changeHiResFix() {
|
||||||
document
|
document
|
||||||
.querySelectorAll(".hrfix")
|
.querySelectorAll(".hrfix")
|
||||||
.forEach((el) => el.classList.remove("invisible"));
|
.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 {
|
} else {
|
||||||
document
|
document
|
||||||
.querySelectorAll(".hrfix")
|
.querySelectorAll(".hrfix")
|
||||||
.forEach((el) => el.classList.add("invisible"));
|
.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() {
|
function changeRestoreFaces() {
|
||||||
stableDiffusionData.restore_faces = Boolean(
|
stableDiffusionData.restore_faces = Boolean(
|
||||||
document.getElementById("cbxRestoreFaces").checked
|
document.getElementById("cbxRestoreFaces").checked
|
||||||
|
@ -845,7 +840,17 @@ async function getUpscalers() {
|
||||||
.split(",")
|
.split(",")
|
||||||
.map((v) => v.trim()); // need "None" for stupid hrfix changes razza frazza
|
.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
|
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");
|
||||||
|
upscalersPlusNone.push("Latent (antialiased)");
|
||||||
|
upscalersPlusNone.push("Latent (bicubic)");
|
||||||
|
upscalersPlusNone.push("Latent (bicubic, antialiased)");
|
||||||
upscalersPlusNone.push("Latent (nearest)"); // GRUMBLE GRUMBLE
|
upscalersPlusNone.push("Latent (nearest)"); // GRUMBLE GRUMBLE
|
||||||
|
|
||||||
upscalerAutoComplete.options = upscalers.map((u) => {
|
upscalerAutoComplete.options = upscalers.map((u) => {
|
||||||
|
|
|
@ -844,20 +844,20 @@ const dream_generate_callback = async (bb, resolution, state) => {
|
||||||
|
|
||||||
var newWidth = Math.floor(request.width / request.hr_scale);
|
var newWidth = Math.floor(request.width / request.hr_scale);
|
||||||
var newHeight = Math.floor(request.height / request.hr_scale);
|
var newHeight = Math.floor(request.height / request.hr_scale);
|
||||||
request.hr_resize_x = stableDiffusionData.hr_resize_x;
|
if (stableDiffusionData.hr_square_aspect) {
|
||||||
request.hr_resize_y = stableDiffusionData.hr_resize_y;
|
larger = newWidth > newHeight ? newWidth : newHeight;
|
||||||
request.width =
|
newWidth = larger;
|
||||||
stableDiffusionData.hr_resize_x || stableDiffusionData.hr_resize_y > 0
|
newHeight = larger;
|
||||||
? request.width
|
}
|
||||||
: newWidth;
|
request.hr_resize_x = request.width;
|
||||||
request.height =
|
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
|
||||||
stableDiffusionData.hr_resize_x || stableDiffusionData.hr_resize_y > 0
|
request.width = newWidth;
|
||||||
? request.height
|
request.height = newHeight;
|
||||||
: 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For compatibility with the old HRFix API
|
// For compatibility with the old HRFix API
|
||||||
if (global.isOldHRFix && request.enable_hr) {
|
if (global.isOldHRFix && request.enable_hr) {
|
||||||
|
// For compatibility with the old HRFix API
|
||||||
request.firstphase_width = request.width / 2;
|
request.firstphase_width = request.width / 2;
|
||||||
request.firstphase_height = request.height / 2;
|
request.firstphase_height = request.height / 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue