"emergency" fix to just get upscalers working again

temporary as hell hardcoded list of "should be available to everyone from a fresh install" upscalers, subject to change upon bug reports
This commit is contained in:
tim h 2023-01-23 17:58:16 -06:00
parent cb36c2b599
commit 85776d8637
2 changed files with 43 additions and 31 deletions

View file

@ -209,7 +209,7 @@
<br /> <br />
<span id="version"> <span id="version">
<a href="https://github.com/zero01101/openOutpaint" target="_blank"> <a href="https://github.com/zero01101/openOutpaint" target="_blank">
Alpha release v0.0.13 Alpha release v0.0.13.1
</a> </a>
<br /> <br />
<a <a
@ -367,7 +367,7 @@
<!-- Content --> <!-- Content -->
<script src="js/prompt.js?v=7a1c68c" type="text/javascript"></script> <script src="js/prompt.js?v=7a1c68c" type="text/javascript"></script>
<script src="js/index.js?v=c4a7bed" type="text/javascript"></script> <script src="js/index.js?v=4c9e978" type="text/javascript"></script>
<script <script
src="js/ui/floating/history.js?v=fc92d14" src="js/ui/floating/history.js?v=fc92d14"

View file

@ -881,38 +881,48 @@ async function getUpscalers() {
*/ */
// hacky way to get the correct list of upscalers // hacky way to get the correct list of upscalers
var extras_url = // var extras_url =
document.getElementById("host").value + "/sdapi/v1/extra-single-image/"; // endpoint for upscaling, needed for the hacky way to get the correct list of upscalers // document.getElementById("host").value + "/sdapi/v1/extra-single-image/"; // endpoint for upscaling, needed for the hacky way to get the correct list of upscalers
var empty_image = document.createElement("canvas"); // var purposefully_incorrect_data = {
empty_image.width = 1; // resize_mode: 0, // 0 = just resize, 1 = crop and resize, 2 = resize and fill i assume based on theimg2img tabs options
empty_image.height = 1; // upscaling_resize: 2,
var purposefully_incorrect_data = { // upscaler_1: "fake_upscaler",
resize_mode: 0, // 0 = just resize, 1 = crop and resize, 2 = resize and fill i assume based on theimg2img tabs options // image: empty_image.toDataURL(),
upscaling_resize: 2, // };
upscaler_1: "fake_upscaler",
image: empty_image.toDataURL(), upscalers = [
}; "Lanczos",
"Nearest",
"LDSR",
"SwinIR",
"R-ESRGAN General 4xV3",
"R-ESRGAN General WDN 4xV3",
"R-ESRGAN AnimeVideo",
"R-ESRGAN 4x+",
"R-ESRGAN 4x+ Anime6B",
"R-ESRGAN 2x+",
];
try { try {
const response = await fetch(extras_url, { // const response = await fetch(extras_url, {
method: "POST", // method: "POST",
headers: { // headers: {
Accept: "application/json", // Accept: "application/json",
"Content-Type": "application/json", // "Content-Type": "application/json",
}, // },
body: JSON.stringify(purposefully_incorrect_data), // body: JSON.stringify(purposefully_incorrect_data),
}); // });
const data = await response.json(); // const data = await response.json();
console.log( // console.log(
"[index] purposefully_incorrect_data response, ignore above error" // "[index] purposefully_incorrect_data response, ignore above error"
); // );
// result = purposefully_incorrect_data response: Invalid upscaler, needs to be on of these: None , Lanczos , Nearest , LDSR , BSRGAN , R-ESRGAN General 4xV3 , R-ESRGAN 4x+ Anime6B , ScuNET , ScuNET PSNR , SwinIR_4x // // result = purposefully_incorrect_data response: Invalid upscaler, needs to be on of these: None , Lanczos , Nearest , LDSR , BSRGAN , R-ESRGAN General 4xV3 , R-ESRGAN 4x+ Anime6B , ScuNET , ScuNET PSNR , SwinIR_4x
const upscalersPlusNone = data.detail // const upscalersPlusNone = data.detail
.split(": ")[1] // .split(": ")[1]
.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([ // upscalersPlusNone.push([
// "Latent", // "Latent",
// "Latent (antialiased)", // "Latent (antialiased)",
@ -920,6 +930,8 @@ async function getUpscalers() {
// "Latent (bicubic, antialiased)", // "Latent (bicubic, antialiased)",
// "Latent (nearest)", // "Latent (nearest)",
// ]); // ]);
const upscalersPlusNone = [...upscalers];
upscalersPlusNone.unshift("None"); //this is absurd
upscalersPlusNone.push("Latent"); upscalersPlusNone.push("Latent");
upscalersPlusNone.push("Latent (antialiased)"); upscalersPlusNone.push("Latent (antialiased)");
upscalersPlusNone.push("Latent (bicubic)"); upscalersPlusNone.push("Latent (bicubic)");