-
-
-
-
+
+
+
+
+
-
+
@@ -341,7 +341,7 @@
-
+
-
+
diff --git a/js/global.js b/js/global.js
index 72cb565..91d0f81 100644
--- a/js/global.js
+++ b/js/global.js
@@ -50,6 +50,9 @@ const global = {
toggledebug() {
this.debug = !this.debug;
},
+
+ // HRFix compatibility shenanigans
+ isOldHRFix: false,
};
global._firstRun = !localStorage.getItem("openoutpaint/host");
diff --git a/js/index.js b/js/index.js
index a2a7ae8..1424164 100644
--- a/js/index.js
+++ b/js/index.js
@@ -345,12 +345,16 @@ async function testHostConnection() {
);
const optionsdata = await response.json();
if (optionsdata["use_scale_latent_for_hires_fix"]) {
- const message = `You are using an outdated version of A1111 webUI.\nThe HRfix options will not work until you update to at least commit ef27a18 or newer.\n(https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/ef27a18b6b7cb1a8eebdc9b2e88d25baf2c2414d)\nHRfix options have been disabled.`;
- console.error(message);
+ const message = `You are using an outdated version of A1111 webUI.\nThe HRfix options will not work until you update to at least commit ef27a18 or newer.\n(https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/ef27a18b6b7cb1a8eebdc9b2e88d25baf2c2414d)\nHRfix will fallback to half-resolution only.`;
+ console.warn(message);
if (notify) alert(message);
+ // Hide all new hrfix options
document
- .getElementById("cbxHRFix")
- .setAttribute("disabled", "disabled");
+ .querySelectorAll(".hrfix")
+ .forEach((el) => (el.style.display = "none"));
+
+ // We are using old HRFix
+ global.isOldHRFix = true;
stableDiffusionData.enable_hr = false;
}
switch (response.status) {
diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js
index 1486b67..e7d7048 100644
--- a/js/ui/tool/dream.js
+++ b/js/ui/tool/dream.js
@@ -141,41 +141,7 @@ const _dream = async (endpoint, request) => {
let data = null;
try {
generating(true);
- if (
- endpoint == "txt2img" &&
- request.enable_hr &&
- localStorage.getItem("openoutpaint/settings.hrfix-liar") == "true"
- ) {
- /**
- * 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
- 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;
- request.height = newHeight;
- }
- if (endpoint == "txt2img") {
- request.denoising_strength = stableDiffusionData.hr_denoising_strength;
- }
const response = await fetch(apiURL, {
method: "POST",
headers: {
@@ -849,6 +815,50 @@ 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"
+ ) {
+ /**
+ * 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
+ 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;
+ request.height = newHeight;
+ }
+
+ // For compatibility with the old HRFix API
+ if (global.isOldHRFix && request.enable_hr) {
+ request.firstphase_width = request.width / 2;
+ request.firstphase_height = request.height / 2;
+ }
+
+ // Only set this if HRFix is enabled in the first place
+ request.denoising_strength = request.enable_hr
+ ? stableDiffusionData.hr_denoising_strength
+ : 1;
+
// Dream
_generate("txt2img", request, bb);
} else {