experimental? newer hrfix stuff

This commit is contained in:
tim h 2023-01-04 20:00:51 -06:00
parent ef583a2135
commit 3c596e6a4c
5 changed files with 90 additions and 23 deletions

View file

@ -644,3 +644,9 @@ select > .style-select-option:active {
.button.tool.active {
background-color: rgb(60, 60, 130);
}
/* Miscellaneous garbage */
.thirdwidth {
max-width: 33%;
}

View file

@ -7,7 +7,7 @@
<link href="css/colors.css?v=3f81e80" rel="stylesheet" />
<link href="css/icons.css?v=caa702e" rel="stylesheet" />
<link href="css/index.css?v=69d3b9e" rel="stylesheet" />
<link href="css/index.css?v=5b8d4d6" rel="stylesheet" />
<link href="css/layers.css?v=b4fbf61" rel="stylesheet" />
<link href="css/ui/generic.css?v=4b9afe2" rel="stylesheet" />
@ -100,8 +100,31 @@
<input type="checkbox" id="cbxHRFix" onchange="changeHiResFix()" />
<label for="cbxHRFix">Apply txt2img HRfix</label>
<br />
<label class="hrfix">Resize to (>0 overrides scale):</label>
<br class="hrfix" />
<label for="hrfOutX" class="hrfix">X:</label>
<input
type="number"
id="hr_resize_x"
onchange="changeHRFX()"
min="0"
max="2048"
value="0"
step="8"
class="hrfix thirdwidth" />
<label for="hrfOutY" class="hrfix">Y:</label>
<input
type="number"
id="hr_resize_y"
onchange="changeHRFY()"
min="0"
max="2048"
value="0"
step="8"
class="hrfix thirdwidth" />
<div id="hrFixScale" class="hrfix"></div>
<div id="hrFixLockPx" class="hrfix"></div>
<div id="hrFixSteps" class="hrfix"></div>
<label id="hrFixLabel" class="hrfix">Choose HRfix upscaler</label>
<div id="hrFixUpscaler" class="hrfix"></div>
<div id="hrDenoising" class="hrfix"></div>
@ -323,7 +346,7 @@
<script src="js/global.js?v=3a1cde6" type="text/javascript"></script>
<!-- Base Libs -->
<script src="js/lib/util.js?v=7f6847c" type="text/javascript"></script>
<script src="js/lib/util.js?v=5838390" type="text/javascript"></script>
<script src="js/lib/events.js?v=2ab7933" type="text/javascript"></script>
<script src="js/lib/input.js?v=09298ac" type="text/javascript"></script>
<script src="js/lib/layers.js?v=a1f8aea" type="text/javascript"></script>
@ -341,7 +364,7 @@
<!-- Content -->
<script src="js/prompt.js?v=7a1c68c" type="text/javascript"></script>
<script src="js/index.js?v=afc36b6" type="text/javascript"></script>
<script src="js/index.js?v=87cef1a" type="text/javascript"></script>
<script
src="js/ui/floating/history.js?v=fc92d14"
@ -352,10 +375,10 @@
<!-- Load Tools -->
<script
src="js/ui/tool/generic.js?v=2bcd36d"
src="js/ui/tool/generic.js?v=f1a19a4"
type="text/javascript"></script>
<script src="js/ui/tool/dream.js?v=1f10ae6" type="text/javascript"></script>
<script src="js/ui/tool/dream.js?v=0c4379b" type="text/javascript"></script>
<script
src="js/ui/tool/maskbrush.js?v=1e8a893"
type="text/javascript"></script>

View file

@ -111,6 +111,9 @@ var stableDiffusionData = {
//firstphase_height: 0, //20230102 welp looks like the entire way HRfix is implemented has become bonkersly different
hr_scale: 2.0,
hr_upscaler: "None",
hr_second_pass_steps: 0,
hr_resize_x: 0,
hr_resize_y: 0,
styles: [],
// here's some more fields that might be useful
@ -679,6 +682,17 @@ const lockPxSlider = makeSlider(
1
);
const hrStepsSlider = makeSlider(
"HRfix Steps",
document.getElementById("hrFixSteps"),
"hr_second_pass_steps",
0,
localStorage.getItem("openoutpaint/settings.max-steps") || 70,
5,
30,
1
);
function changeMaskBlur() {
stableDiffusionData.mask_blur = parseInt(
document.getElementById("maskBlur").value
@ -691,29 +705,45 @@ function changeSeed() {
localStorage.setItem("openoutpaint/seed", stableDiffusionData.seed);
}
function changeHRFX() {
stableDiffusionData.hr_resize_x =
document.getElementById("hr_resize_x").value;
}
function changeHRFY() {
stableDiffusionData.hr_resize_y =
document.getElementById("hr_resize_y").value;
}
function changeHiResFix() {
stableDiffusionData.enable_hr = Boolean(
document.getElementById("cbxHRFix").checked
);
localStorage.setItem("openoutpaint/enable_hr", stableDiffusionData.enable_hr);
var hrfSlider = document.getElementById("hrFixScale");
var hrfOpotions = document.getElementById("hrFixUpscaler");
var hrfLabel = document.getElementById("hrFixLabel");
var hrfDenoiseSlider = document.getElementById("hrDenoising");
var hrfLockPxSlider = document.getElementById("hrFixLockPx");
// var hrfSlider = document.getElementById("hrFixScale");
// var hrfOpotions = document.getElementById("hrFixUpscaler");
// var hrfLabel = document.getElementById("hrFixLabel");
// var hrfDenoiseSlider = document.getElementById("hrDenoising");
// var hrfLockPxSlider = document.getElementById("hrFixLockPx");
if (stableDiffusionData.enable_hr) {
hrfSlider.classList.remove("invisible");
hrfOpotions.classList.remove("invisible");
hrfLabel.classList.remove("invisible");
hrfDenoiseSlider.classList.remove("invisible");
hrfLockPxSlider.classList.remove("invisible");
document
.querySelectorAll(".hrfix")
.forEach((el) => el.classList.remove("invisible"));
// hrfSlider.classList.remove("invisible");
// hrfOpotions.classList.remove("invisible");
// hrfLabel.classList.remove("invisible");
// hrfDenoiseSlider.classList.remove("invisible");
// hrfLockPxSlider.classList.remove("invisible");
//state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.add("invisible");
} else {
hrfSlider.classList.add("invisible");
hrfOpotions.classList.add("invisible");
hrfLabel.classList.add("invisible");
hrfDenoiseSlider.classList.add("invisible");
hrfLockPxSlider.classList.add("invisible");
document
.querySelectorAll(".hrfix")
.forEach((el) => el.classList.add("invisible"));
// hrfSlider.classList.add("invisible");
// hrfOpotions.classList.add("invisible");
// hrfLabel.classList.add("invisible");
// hrfDenoiseSlider.classList.add("invisible");
// hrfLockPxSlider.classList.add("invisible");
//state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.remove("invisible");
}
}

View file

@ -844,8 +844,16 @@ const dream_generate_callback = async (bb, resolution, state) => {
var newWidth = Math.floor(request.width / request.hr_scale);
var newHeight = Math.floor(request.height / request.hr_scale);
request.width = newWidth;
request.height = newHeight;
request.hr_resize_x = stableDiffusionData.hr_resize_x;
request.hr_resize_y = stableDiffusionData.hr_resize_y;
request.width =
stableDiffusionData.hr_resize_x || stableDiffusionData.hr_resize_y > 0
? request.width
: newWidth;
request.height =
stableDiffusionData.hr_resize_x || stableDiffusionData.hr_resize_y > 0
? request.height
: newHeight; //in webUI if _either_ x or y is > 0 then their values are used over scale as per https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/81490780949fffed77493b4bd741e96ec737fe27#diff-ddc07d50fa3b043925b1e831b1373976798d62c9f5c11fcb16c6c830bd3857cdR104
}
// For compatibility with the old HRFix API

View file

@ -7,7 +7,7 @@
<link href="../css/colors.css?v=3f81e80" rel="stylesheet" />
<link href="../css/icons.css?v=caa702e" rel="stylesheet" />
<link href="../css/index.css?v=69d3b9e" rel="stylesheet" />
<link href="../css/index.css?v=5b8d4d6" rel="stylesheet" />
<link href="../css/layers.css?v=b4fbf61" rel="stylesheet" />
<link href="../css/ui/generic.css?v=4b9afe2" rel="stylesheet" />