zero01101 / openOutpaint

local offline javascript and html canvas outpainting gizmo for stable diffusion webUI API 🐠
MIT License
503 stars 44 forks source link

Firstpass height and width with hi-res fix in img2img? #137

Closed zero01101 closed 1 year ago

zero01101 commented 1 year ago

Discussed in https://github.com/zero01101/openOutpaint/discussions/136

Originally posted by **Drakmour** December 30, 2022 I can't find where to put the initial resolution for hi-res fix in img2img of OpenOutpaint. Like firstpass height and width in text2img. Is there such option? I've read that right now it decrease the resolution x2 and then generate, but if my image is more than 1024 and is not square it still result in morbid multiple characters. I'd like to have an option to make firstpass 512x512 and then resize to my end resolution. It 99% works in text2img and should work in img2img. In text2img I get random result, while in img2img I can draw a sketch of pose of character myself to have much more control of the result.
zero01101 commented 1 year ago

hires fix is a txt2img function exposed in A1111 webUI and thus can't be applied with img2img - the "inpaint full resolution" option is probably the most adjacently similar function for img2img :/

dream/txt2img automatic hrfix option previously calculated its x/y values by simply halving the value of the resolution slider and applying it to both x and y axes as reticles used to be purely square.

testing branch commit https://github.com/zero01101/openOutpaint/commit/c9a768d406503405b894eea5d44ebb1ab133489b adds a hacky (what a surprise) quick fix to set the x/y values against the actual returned boundary box dimensions.

zero01101 commented 1 year ago

alright, actually @Drakmour if you've already ran git checkout testing then just run another git pull; i've just added an "hrfix lock px" slider here: image

basically, it steps between 0/256/512/768 - set it to 0 to turn off max pixel values, and you can of course click the slider to type a manual integer value, but tl;dr - set the slider and if the automatic hrfix value is > slider value, slider value is used, either X or Y axis.

for example, an image dreamed at 960x1408 with a lock value of 512 sets firstpass height to 512, and firstpass width to 480. a 1920x1856 clamped to 512 firstpasses at... 512x512 of course. 768 was chosen as a ceiling for the moment since that's the largest training data any model's been based on so far.

anyway, let me know if this is more useful :)

Drakmour commented 1 year ago

I don't know, maybe it's just me and my bad skills, but now img2img doesn't do anything on any denoise level. It just sharpens image a bit and nothing else changes. With or without tick in HRfix. I just put git pull during launch and I think it automatically updated. Or I still need to do "git checkout testing". A still didn't understand how to do it. :-D You said this: cd \oo git checkout testing

My extention path is this - c:\SUPER SD 2.0\stable-diffusion-webui\extensions\openOutpaint-webUI-extension\ I tried to put "git checkout testing" in the line of this adress. It popups at half a second then disappears. I even dunno what was written there, or was it. :-)

Drakmour commented 1 year ago

I found a reason why I had no results. In img2img if you have no mask you have to put tick in "invert mask", or it will try to img2img non-existing mask. If you put inverted mask, it will img2img the whole image cuz it is the "inverted" part of non existing mask. :-D A bit confusing.

zero01101 commented 1 year ago

hrfix option doesn't happen at all anywhere if you're using img2img - it'll only do anything whatsoever on a completely new dream over blank space as that's the only txt2img operation that occurs in openOutpaint. inpainting/outpainting/img2img tool all use the img2img functionality of A1111 which doesn't have hrfix anywhere in the process chain.

otherwise, yeah, the invert mask option should be enabled when you select the img2img tool unless you'd disabled it earlier in the session, but i can see how that'd be a bit awkward; there's now more clarity regarding the option in the manual.

My extention path is this - c:\SUPER SD 2.0\stable-diffusion-webui\extensions\openOutpaint-webUI-extension

ah, wasn't aware you were using the extension. you might've checked out the testing branch for that instead.

so you'd do the following:

that'll switch the openOutpaint gitmodule in the extension to the testing branch and should put the extension back on the main branch. the extension will try to update the submodule each time it's initialized (whenever gradio re/starts) so you may end up with unexpected bugs/side effects if you stay on the testing branch as that's where stuff in testing goes. you'll likely want to switch back to main by replacing "testing" back to "main" in the .gitmodules file

Drakmour commented 1 year ago

Ok. I switched to test branch. Thanks for the explanation. But the fact that there is no hrfix option in A1111 itself depresses me much. :-( How am I supposed to make a img2img on resolutions higher than 512x512 if it results in adding more mutations. :-( Ok, Is there a way to add options like A1111 has in img2img like crop&resize, resize&fill, and... just resize (latend upscale)... I haven't even seen the last one. I wonder when it was added.

zero01101 commented 1 year ago

How am I supposed to make a img2img on resolutions higher than 512x512 if it results in adding more mutations. :-(

yeah, unfortunately all i've got on that one is "work in greater detail using smaller regions" :/ not much of a fix really

i was actually looking into adding a selector for the img2img inpaint modes last night and those should be added to openOutpaint fairly soon; can't give an exact timeframe unfortunately due to holidays and family events, but those are definitely planned to show up 👍

Drakmour commented 1 year ago

Good to know. I just can't come up with a plan ho to make img2img without morbid results. If I make 512x512 and then try to upscale, it's pointless cuz 512 has so much less details than 1200+, and every img2img upscale from 512 to 1200+ even with low denoising will still get morbid results during the generation and will slowly change image from the initial one... :-(

zero01101 commented 1 year ago

img2img inpaint mode selector should exist now on the testing branch; it's nothing fancy, just delivers what it says on the tin :)

zero01101 commented 1 year ago

hey well thanks to the massive changes to HRfix, none of the above is even relevant anymore so that's neat

there's a new hrfix scale slider to work like a traditional upscaler, and a "lie to hrfix" option in the gear/config menu which will set the resolution requested from webUI to the divided value against the hrfix scale; that way, webUI "upscales" an image from... whatever resolution into one that'll fit the reticle correctly

zero01101 commented 1 year ago

closing this as moot given the upstream HRfix craziness of late, plus the original bug of non-square ratios was fixed, plus plus HRfix isn't a thing in img2img in the first place