Merge branch 'main' into manual-scripts

# Conflicts:
#	index.html
This commit is contained in:
tim h 2023-01-24 22:12:50 -06:00
commit 958dca6b1a
2 changed files with 47 additions and 121 deletions

View file

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

View file

@ -849,27 +849,27 @@ function drawBackground() {
}
async function getUpscalers() {
/*
so for some reason when upscalers request returns upscalers, the real-esrgan model names are incorrect, and need to be fetched from /sdapi/v1/realesrgan-models
also the realesrgan models returned are not all correct, extra fun!
LDSR seems to have problems so we dont add that either -> RuntimeError: Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor
need to figure out why that is, if you dont get this error then you can add it back in
Hacky way to get the correct list all in one go is to purposefully make an incorrect request, which then returns
{ detail: "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" }
from which we can extract the correct list of upscalers
*/
// hacky way to get the correct list of upscalers
// 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
// var purposefully_incorrect_data = {
// resize_mode: 0, // 0 = just resize, 1 = crop and resize, 2 = resize and fill i assume based on theimg2img tabs options
// upscaling_resize: 2,
// upscaler_1: "fake_upscaler",
// image: empty_image.toDataURL(),
// };
var url = document.getElementById("host").value + "/sdapi/v1/upscalers";
let upscalers = [];
try {
const response = await fetch(url, {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
});
const data = await response.json();
for (var i = 0; i < data.length; i++) {
if (data[i].name.includes("None")) {
continue;
}
upscalers.push(data[i].name);
}
} catch (e) {
console.warn("[index] Failed to fetch upscalers:");
console.warn(e);
upscalers = [
"Lanczos",
"Nearest",
@ -882,41 +882,14 @@ async function getUpscalers() {
"R-ESRGAN 4x+ Anime6B",
"R-ESRGAN 2x+",
];
try {
// const response = await fetch(extras_url, {
// method: "POST",
// headers: {
// Accept: "application/json",
// "Content-Type": "application/json",
// },
// body: JSON.stringify(purposefully_incorrect_data),
// });
// const data = await response.json();
// console.log(
// "[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
// const upscalersPlusNone = data.detail
// .split(": ")[1]
// .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)",
// ]);
}
const upscalersPlusNone = [...upscalers];
upscalersPlusNone.unshift("None"); //this is absurd
upscalersPlusNone.unshift("None");
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)");
upscalerAutoComplete.options = upscalers.map((u) => {
return {name: u, value: u};
@ -930,53 +903,6 @@ async function getUpscalers() {
localStorage.getItem("openoutpaint/hr_upscaler") === null
? "None"
: localStorage.getItem("openoutpaint/hr_upscaler");
} catch (e) {
console.warn("[index] Failed to fetch upscalers:");
console.warn(e);
}
/* THE NON HACKY WAY THAT I SIMPLY COULD NOT GET TO PRODUCE A LIST WITHOUT NON WORKING UPSCALERS, FEEL FREE TO TRY AND FIGURE IT OUT
var url = document.getElementById("host").value + "/sdapi/v1/upscalers";
var realesrgan_url = document.getElementById("host").value + "/sdapi/v1/realesrgan-models";
// get upscalers
fetch(url)
.then((response) => response.json())
.then((data) => {
console.log(data);
for (var i = 0; i < data.length; i++) {
var option = document.createElement("option");
if (data[i].name.includes("ESRGAN") || data[i].name.includes("LDSR")) {
continue;
}
option.text = data[i].name;
upscalerSelect.add(option);
}
})
.catch((error) => {
alert(
"Error getting upscalers, please check console for additional info\n" +
error
);
});
// fetch realesrgan models separately
fetch(realesrgan_url)
.then((response) => response.json())
.then((data) => {
var model = data;
for(var i = 0; i < model.length; i++){
let option = document.createElement("option");
option.text = model[i].name;
option.value = model[i].name;
upscalerSelect.add(option);
}
})
*/
}
async function getModels(refresh = false) {