return of HRfix lock px

not sure if useful or i'm just salty
This commit is contained in:
tim h 2023-01-03 21:41:03 -06:00
parent 55b7f3dbc1
commit 227c7839f3
3 changed files with 42 additions and 5 deletions

View file

@ -101,6 +101,7 @@
<label for="cbxHRFix">Apply txt2img HRfix</label> <label for="cbxHRFix">Apply txt2img HRfix</label>
<br /> <br />
<div id="hrFixScale"></div> <div id="hrFixScale"></div>
<div id="hrFixLockPx"></div>
<label id="hrFixLabel">Choose HRfix upscaler</label> <label id="hrFixLabel">Choose HRfix upscaler</label>
<div id="hrFixUpscaler"></div> <div id="hrFixUpscaler"></div>
<div id="hrDenoising"></div> <div id="hrDenoising"></div>
@ -322,7 +323,7 @@
<script src="js/global.js?v=1807d6e" type="text/javascript"></script> <script src="js/global.js?v=1807d6e" type="text/javascript"></script>
<!-- Base Libs --> <!-- 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/events.js?v=2ab7933" type="text/javascript"></script>
<script src="js/lib/input.js?v=09298ac" 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> <script src="js/lib/layers.js?v=a1f8aea" type="text/javascript"></script>
@ -340,7 +341,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=62ccd18" type="text/javascript"></script> <script src="js/index.js?v=57dca90" type="text/javascript"></script>
<script <script
src="js/ui/floating/history.js?v=fc92d14" src="js/ui/floating/history.js?v=fc92d14"
@ -351,10 +352,10 @@
<!-- Load Tools --> <!-- Load Tools -->
<script <script
src="js/ui/tool/generic.js?v=2bcd36d" src="js/ui/tool/generic.js?v=f1a19a4"
type="text/javascript"></script> type="text/javascript"></script>
<script src="js/ui/tool/dream.js?v=d408feb" type="text/javascript"></script> <script src="js/ui/tool/dream.js?v=c4d85f5" 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

@ -642,7 +642,7 @@ makeSlider(
); );
// 20230102 grumble grumble // 20230102 grumble grumble
makeSlider( const hrFixScaleSlider = makeSlider(
"HRfix Scale", "HRfix Scale",
document.getElementById("hrFixScale"), document.getElementById("hrFixScale"),
"hr_scale", "hr_scale",
@ -664,6 +664,17 @@ makeSlider(
0.01 0.01
); );
const lockPxSlider = makeSlider(
"HRfix Autoscale Lock Px.",
document.getElementById("hrFixLockPx"),
"hr_fix_lock_px",
0,
1024,
256,
0,
1
);
function changeMaskBlur() { function changeMaskBlur() {
stableDiffusionData.mask_blur = parseInt( stableDiffusionData.mask_blur = parseInt(
document.getElementById("maskBlur").value document.getElementById("maskBlur").value
@ -685,17 +696,20 @@ function changeHiResFix() {
var hrfOpotions = document.getElementById("hrFixUpscaler"); var hrfOpotions = document.getElementById("hrFixUpscaler");
var hrfLabel = document.getElementById("hrFixLabel"); var hrfLabel = document.getElementById("hrFixLabel");
var hrfDenoiseSlider = document.getElementById("hrDenoising"); var hrfDenoiseSlider = document.getElementById("hrDenoising");
var hrfLockPxSlider = document.getElementById("hrFixLockPx");
if (stableDiffusionData.enable_hr) { if (stableDiffusionData.enable_hr) {
hrfSlider.classList.remove("invisible"); hrfSlider.classList.remove("invisible");
hrfOpotions.classList.remove("invisible"); hrfOpotions.classList.remove("invisible");
hrfLabel.classList.remove("invisible"); hrfLabel.classList.remove("invisible");
hrfDenoiseSlider.classList.remove("invisible"); hrfDenoiseSlider.classList.remove("invisible");
hrfLockPxSlider.classList.remove("invisible");
//state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.add("invisible"); //state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.add("invisible");
} else { } else {
hrfSlider.classList.add("invisible"); hrfSlider.classList.add("invisible");
hrfOpotions.classList.add("invisible"); hrfOpotions.classList.add("invisible");
hrfLabel.classList.add("invisible"); hrfLabel.classList.add("invisible");
hrfDenoiseSlider.classList.add("invisible"); hrfDenoiseSlider.classList.add("invisible");
hrfLockPxSlider.classList.add("invisible");
//state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.remove("invisible"); //state.ctxmenu.keepUnmaskedBlurSliderLinebreak.classList.remove("invisible");
} }
} }
@ -1150,6 +1164,11 @@ function loadSettings() {
localStorage.getItem("openoutpaint/hr_denoising_strength") === null localStorage.getItem("openoutpaint/hr_denoising_strength") === null
? 0.7 ? 0.7
: localStorage.getItem("openoutpaint/hr_denoising_strength"); : localStorage.getItem("openoutpaint/hr_denoising_strength");
let _hrfix_lock_px =
localStorage.getItem("openoutpaint/hr_fix_lock_px") === null
? 0
: localStorage.getItem("openoutpaint/hr_fix_lock_px");
// set the values into the UI // set the values into the UI
document.getElementById("maskBlur").value = Number(_mask_blur); document.getElementById("maskBlur").value = Number(_mask_blur);
document.getElementById("seed").value = Number(_seed); document.getElementById("seed").value = Number(_seed);
@ -1159,6 +1178,7 @@ function loadSettings() {
Boolean(_sync_cursor_size); Boolean(_sync_cursor_size);
document.getElementById("hrFixScale").value = Number(_hrfix_scale); document.getElementById("hrFixScale").value = Number(_hrfix_scale);
document.getElementById("hrDenoising").value = Number(_hrfix_denoising); document.getElementById("hrDenoising").value = Number(_hrfix_denoising);
document.getElementById("hrFixLockPx").value = Number(_hrfix_lock_px);
} }
imageCollection.element.addEventListener( imageCollection.element.addEventListener(

View file

@ -141,6 +141,22 @@ const _dream = async (endpoint, request) => {
* we cheekily lie to SD and tell it that the original dimensions are _divided_ * 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 * by the scale factor so it returns something about the same size as we wanted initially
*/ */
// ok so instead, only do that if stableDiffusionData.hr_fix_lock_px > 0
if (stableDiffusionData.hr_fix_lock_px > 0) {
// find the appropriate scale factor for hrfix
var widthFactor =
request.width / stableDiffusionData.hr_fix_lock_px <= 4
? request.width / stableDiffusionData.hr_fix_lock_px
: 4;
var heightFactor =
request.height / stableDiffusionData.hr_fix_lock_px <= 4
? request.height / stableDiffusionData.hr_fix_lock_px
: 4;
var factor = heightFactor > widthFactor ? heightFactor : widthFactor;
request.hr_scale = hrFixScaleSlider.value = factor < 1 ? 1 : factor;
}
var newWidth = Math.floor(request.width / request.hr_scale); var newWidth = Math.floor(request.width / request.hr_scale);
var newHeight = Math.floor(request.height / request.hr_scale); var newHeight = Math.floor(request.height / request.hr_scale);
request.width = newWidth; request.width = newWidth;