reenables LDSR, ran prettier, version bump ( ͡° ͜ʖ ͡°)
Former-commit-id: 2c75f84ad9a88f7454a5469bba8c4c90ca09186a
This commit is contained in:
parent
7370aba4d3
commit
9a796ecd67
2 changed files with 51 additions and 46 deletions
|
@ -117,7 +117,7 @@
|
||||||
<span id="snapY"></span><br />
|
<span id="snapY"></span><br />
|
||||||
<label for="heldButton">Mouse button:</label>
|
<label for="heldButton">Mouse button:</label>
|
||||||
<span id="heldButton"></span><br />
|
<span id="heldButton"></span><br />
|
||||||
<span id="version">Alpha release v0.0.6.6</span>
|
<span id="version">Alpha release v0.0.6.9</span> <!-- 𝓃𝒾𝒸𝑒 -->
|
||||||
<br />
|
<br />
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
|
|
91
js/index.js
91
js/index.js
|
@ -905,8 +905,8 @@ function cropCanvas(sourceCanvas) {
|
||||||
return a - b;
|
return a - b;
|
||||||
});
|
});
|
||||||
var n = pix.x.length - 1;
|
var n = pix.x.length - 1;
|
||||||
w = (pix.x[n] - pix.x[0])+1;
|
w = pix.x[n] - pix.x[0] + 1;
|
||||||
h = (pix.y[n] - pix.y[0])+1;
|
h = pix.y[n] - pix.y[0] + 1;
|
||||||
// yup sure looks like it
|
// yup sure looks like it
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -942,7 +942,6 @@ function checkIfWebuiIsRunning() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUpscalers() {
|
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
|
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!
|
also the realesrgan models returned are not all correct, extra fun!
|
||||||
|
@ -956,15 +955,17 @@ function getUpscalers() {
|
||||||
|
|
||||||
// hacky way to get the correct list of upscalers
|
// hacky way to get the correct list of upscalers
|
||||||
var upscalerSelect = document.getElementById("upscalers");
|
var upscalerSelect = document.getElementById("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 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 empty_image = new Image(512, 512);
|
var empty_image = new Image(512, 512);
|
||||||
empty_image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAFCAAAAABCAYAAAChpRsuAAAALklEQVR42u3BAQ0AAAgDoJvc6LeHAybtBgAAAAAAAAAAAAAAAAAAAAAAAAB47QD2wAJ/LnnqGgAAAABJRU5ErkJggg=="; //transparent pixel
|
empty_image.src =
|
||||||
|
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAFCAAAAABCAYAAAChpRsuAAAALklEQVR42u3BAQ0AAAgDoJvc6LeHAybtBgAAAAAAAAAAAAAAAAAAAAAAAAB47QD2wAJ/LnnqGgAAAABJRU5ErkJggg=="; //transparent pixel
|
||||||
var purposefully_incorrect_data = {
|
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
|
"resize-mode": 0, // 0 = just resize, 1 = crop and resize, 2 = resize and fill i assume based on theimg2img tabs options
|
||||||
"upscaling_resize": 2,
|
upscaling_resize: 2,
|
||||||
"upscaler_1": "fake_upscaler",
|
upscaler_1: "fake_upscaler",
|
||||||
"image": empty_image.src,
|
image: empty_image.src,
|
||||||
}
|
};
|
||||||
|
|
||||||
fetch(extras_url, {
|
fetch(extras_url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -974,21 +975,19 @@ function getUpscalers() {
|
||||||
},
|
},
|
||||||
body: JSON.stringify(purposefully_incorrect_data),
|
body: JSON.stringify(purposefully_incorrect_data),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log( "purposefully_incorrect_data response, ignore above error");
|
console.log("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
|
||||||
let upscalers = data.detail.split(": ")[1].trim().split(" , "); // converting the result to a list of upscalers
|
let upscalers = data.detail.split(": ")[1].trim().split(" , "); // converting the result to a list of upscalers
|
||||||
for (var i = 0; i < upscalers.length; i++) {
|
for (var i = 0; i < upscalers.length; i++) {
|
||||||
if(upscalers[i] == "LDSR") continue; // Skip LDSR, see reason in the first comment
|
// if(upscalers[i] == "LDSR") continue; // Skip LDSR, see reason in the first comment // readded because worksonmymachine.jpg but leaving it here in case of, uh, future disaster?
|
||||||
var option = document.createElement("option");
|
var option = document.createElement("option");
|
||||||
option.text = upscalers[i];
|
option.text = upscalers[i];
|
||||||
option.value = upscalers[i];
|
option.value = upscalers[i];
|
||||||
upscalerSelect.add(option);
|
upscalerSelect.add(option);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
/* 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
|
/* 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
|
||||||
|
|
||||||
|
@ -1034,7 +1033,7 @@ function getUpscalers() {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
async function upscaleAndDownload(){
|
async function upscaleAndDownload() {
|
||||||
// Future improvements: some upscalers take a while to upscale, so we should show a loading bar or something, also a slider for the upscale amount
|
// Future improvements: some upscalers take a while to upscale, so we should show a loading bar or something, also a slider for the upscale amount
|
||||||
|
|
||||||
// get cropped canvas, send it to upscaler, download result
|
// get cropped canvas, send it to upscaler, download result
|
||||||
|
@ -1043,14 +1042,15 @@ async function upscaleAndDownload(){
|
||||||
var croppedCanvas = cropCanvas(imgCanvas);
|
var croppedCanvas = cropCanvas(imgCanvas);
|
||||||
if (croppedCanvas != null) {
|
if (croppedCanvas != null) {
|
||||||
var upscaler = document.getElementById("upscalers").value;
|
var upscaler = document.getElementById("upscalers").value;
|
||||||
var url = document.getElementById("host").value + "/sdapi/v1/extra-single-image/";
|
var url =
|
||||||
|
document.getElementById("host").value + "/sdapi/v1/extra-single-image/";
|
||||||
var imgdata = croppedCanvas.toDataURL("image/png");
|
var imgdata = croppedCanvas.toDataURL("image/png");
|
||||||
var data = {
|
var data = {
|
||||||
"resize-mode" : 0, // 0 = just resize, 1 = crop and resize, 2 = resize and fill i assume based on theimg2img tabs options
|
"resize-mode": 0, // 0 = just resize, 1 = crop and resize, 2 = resize and fill i assume based on theimg2img tabs options
|
||||||
"upscaling_resize": upscale_factor,
|
upscaling_resize: upscale_factor,
|
||||||
"upscaler_1": upscaler,
|
upscaler_1: upscaler,
|
||||||
"image": imgdata,
|
image: imgdata,
|
||||||
}
|
};
|
||||||
console.log(data);
|
console.log(data);
|
||||||
await fetch(url, {
|
await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -1060,20 +1060,25 @@ async function upscaleAndDownload(){
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
var link = document.createElement("a");
|
var link = document.createElement("a");
|
||||||
link.download =
|
link.download =
|
||||||
new Date().toISOString().slice(0, 19).replace("T", " ").replace(":", " ") +
|
new Date()
|
||||||
" openOutpaint image upscaler_"+upscaler+".png";
|
.toISOString()
|
||||||
link.href = "data:image/png;base64,"+data["image"];
|
.slice(0, 19)
|
||||||
link.click();
|
.replace("T", " ")
|
||||||
})
|
.replace(":", " ") +
|
||||||
|
" openOutpaint image upscaler_" +
|
||||||
|
upscaler +
|
||||||
|
".png";
|
||||||
|
link.href = "data:image/png;base64," + data["image"];
|
||||||
|
link.click();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
// set default values if not set
|
// set default values if not set
|
||||||
var _sampler =
|
var _sampler =
|
||||||
|
|
Loading…
Reference in a new issue