-
Notifications
You must be signed in to change notification settings - Fork 26k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: hiresfix for img2img #14721
base: dev
Are you sure you want to change the base?
Draft: hiresfix for img2img #14721
Conversation
hr_sampler_name: str = None | ||
hr_prompt: str = '' | ||
hr_negative_prompt: str = '' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved fields and methods connected with hires fix from Txt2Img class into parent class to not dublicate
old_denoising_strength = self.denoising_strength | ||
self.denoising_strength = self.hr_denoising_strength | ||
samples = self.sample_hr_pass(samples, decoded_samples, seeds, subseeds, subseed_strength, prompts) | ||
self.denoising_strength = old_denoising_strength | ||
|
||
if self.mask is not None: | ||
blended_samples = samples * self.nmask + self.init_latent * self.mask |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is problem with inpaint. I can't understand what I need to do, to fit upscaled area into input image. Someone who know, maybe @AUTOMATIC1111, can you fix it?
dev-stable-diffusion-webui/modules/sd_samplers_cfg_denoiser.py", line 113, in apply_blend
blended_latent = current_latent * self.nmask + self.init_latent * self.mask
~~~~~~~~~~~~~~~^~~~~~~~~~~~
RuntimeError: The size of tensor a (128) must match the size of tensor b (64) at non-singleton dimension 3
@@ -666,6 +666,35 @@ def copy_image(img): | |||
|
|||
elif category == "accordions": | |||
with gr.Row(elem_id="img2img_accordions", elem_classes="accordions"): | |||
|
|||
with InputAccordion(False, label="Hires. fix", elem_id="img2img_hr") as enable_hr: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just copied all staff, and changed elem_id s and denoise_straight -> hr_denoise_straight
self.height = self.firstphase_height | ||
|
||
self.cached_hr_uc = StableDiffusionProcessingTxt2Img.cached_hr_uc | ||
self.cached_hr_c = StableDiffusionProcessingTxt2Img.cached_hr_c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like I forgot to change class name
I think it makes more sense to just extend hires fix in txt2img already adds a bunch to complexity to the pip line |
@w-e-w I see, I will try it. I will make alternative pr |
I thought it will hard to implement inpainting hires fix, but it is vice versa easier because I just need to override 1 variable in first pass (upscaler for img2img), and it's very easy for scripts |
1 similar comment
I thought it will hard to implement inpainting hires fix, but it is vice versa easier because I just need to override 1 variable in first pass (upscaler for img2img), and it's very easy for scripts |
yes, look again |
@w-e-w I have quickly explored loopback code, and understood few things:
So I decided to make a new pr with selectable script for img2img[/txt2img], called like |
I have concerted proposing to deprecate hires fix but drop the idea long ago I suggest that you join discord server (if you haven't already) and passed your ideas with the other developers and especially AUTO befor making lots of changes otherwise you work may go to waste discord invire link is on wiki/Contributing |
One more thing, ✨ button takes options from ui. It can takes from selectable script, but it less intuitive. Mb if I call script just "hires fix options" it will be more intuitive
okay |
@light-and-ray Curious if anything came from the discord discussions. I've wanted a ✨ button / HRFix for Img2img for awhile. |
Nope nothing. Implementation in this pr is bad, because it duplicates txt2img hires fix, which is bad. Implementing new hires fix is okay, but nobody is interested I'm not interested too, because for inpaint here it is hard to make, and my extension Replacer has improved hiresfix which now supports custom masks and fixing only one image from gallery. Maybe later I will implement hires fix for non-inpainting img2img as an extension of built-in script. Extension is more likely, because hires fix with no inpaint support looks bad for built-in feature |
Fair enough! Thanks for the info. This draft might be better than nothing for now. I'll try out Replacer as well, maybe its hr-fix could be used stand-alone with a non-matching replacement prompt or something. |
Add Hires. fix option into img2img tab #2213. Useful for generating images with high denoise straight. E.g. photo -> painting
Current implementation has issues:
Checklist: