optionally implements dishonesty to POST request data to make new HRfix actually useful to our needs

This commit is contained in:
tim h 2023-01-02 14:49:47 -06:00
parent 8aa0007c2c
commit 8962d75c60
3 changed files with 30 additions and 2 deletions

View file

@ -313,7 +313,7 @@
<div class="ui separator"></div> <div class="ui separator"></div>
<iframe <iframe
id="page-overlay" id="page-overlay"
src="pages/configuration.html?v=ae8af5d"></iframe> src="pages/configuration.html?v=3d710ce"></iframe>
</div> </div>
</div> </div>
@ -353,7 +353,7 @@
src="js/ui/tool/generic.js?v=2bcd36d" src="js/ui/tool/generic.js?v=2bcd36d"
type="text/javascript"></script> type="text/javascript"></script>
<script src="js/ui/tool/dream.js?v=51b08d9" type="text/javascript"></script> <script src="js/ui/tool/dream.js?v=d6ad22c" type="text/javascript"></script>
<script <script
src="js/ui/tool/maskbrush.js?v=1e8a893" src="js/ui/tool/maskbrush.js?v=1e8a893"
type="text/javascript"></script> type="text/javascript"></script>

View file

@ -130,6 +130,22 @@ const _dream = async (endpoint, request) => {
let data = null; let data = null;
try { try {
generating = true; 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
*/
var newWidth = Math.floor(request.width / request.hr_scale);
var newHeight = Math.floor(request.height / request.hr_scale);
request.width = newWidth;
request.height = newHeight;
}
const response = await fetch(apiURL, { const response = await fetch(apiURL, {
method: "POST", method: "POST",
headers: { headers: {

View file

@ -84,6 +84,10 @@
step="0.1" step="0.1"
value="30.0" /> value="30.0" />
</label> </label>
<label style="display: flex">
Lie to HRfix:
<input id="hrfix-liar" class="canvas-size-input" type="checkbox" />
</label>
<p>Refresh the page to apply settings.</p> <p>Refresh the page to apply settings.</p>
<script> <script>
@ -92,6 +96,7 @@
const maxSteps = document.getElementById("max-steps"); const maxSteps = document.getElementById("max-steps");
const minCfg = document.getElementById("min-cfg"); const minCfg = document.getElementById("min-cfg");
const maxCfg = document.getElementById("max-cfg"); const maxCfg = document.getElementById("max-cfg");
const hrfixLiar = document.getElementById("hrfix-liar");
function writeToLocalStorage() { function writeToLocalStorage() {
localStorage.setItem( localStorage.setItem(
@ -105,6 +110,10 @@
localStorage.setItem("openoutpaint/settings.max-steps", maxSteps.value); localStorage.setItem("openoutpaint/settings.max-steps", maxSteps.value);
localStorage.setItem("openoutpaint/settings.min-cfg", minCfg.value); localStorage.setItem("openoutpaint/settings.min-cfg", minCfg.value);
localStorage.setItem("openoutpaint/settings.max-cfg", maxCfg.value); localStorage.setItem("openoutpaint/settings.max-cfg", maxCfg.value);
localStorage.setItem(
"openoutpaint/settings.hrfix-liar",
hrfixLiar.checked
);
} }
// Loads values from local storage // Loads values from local storage
@ -118,6 +127,8 @@
localStorage.getItem("openoutpaint/settings.min-cfg") || -1; localStorage.getItem("openoutpaint/settings.min-cfg") || -1;
maxCfg.value = maxCfg.value =
localStorage.getItem("openoutpaint/settings.max-cfg") || 30; localStorage.getItem("openoutpaint/settings.max-cfg") || 30;
hrfixLiar.checked =
localStorage.getItem("openoutpaint/settings.hrfix-liar") || true;
writeToLocalStorage(); writeToLocalStorage();
@ -126,6 +137,7 @@
maxSteps.onchange = writeToLocalStorage; maxSteps.onchange = writeToLocalStorage;
minCfg.onchange = writeToLocalStorage; minCfg.onchange = writeToLocalStorage;
maxCfg.onchange = writeToLocalStorage; maxCfg.onchange = writeToLocalStorage;
hrfixLiar.onchange = writeToLocalStorage;
</script> </script>
</body> </body>
</html> </html>