Skip to content
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

more Hr button fix #14626

Merged
merged 7 commits into from
Jan 20, 2024
Merged

more Hr button fix #14626

merged 7 commits into from
Jan 20, 2024

Conversation

w-e-w
Copy link
Collaborator

@w-e-w w-e-w commented Jan 11, 2024

Description

some more fixes to hires fix button

  • disable saving images before highres fix
    makes no sense to save first pass image again
  • allow hires pass to update the existing gallery as opposed to setting all the other images to black
    this allows the user to perform Hr on multiple images from a first pass batch
  • allow hr pass to retrun and update multiple images
    this is basically just for compatibility with my extension https://github.com/w-e-w/sd-webui-hires-fix-tweaks which allows you to generate multiple hr pass images
  • add p.txt2img_upscale attribute as indicator of using txt2img_upscale()
  • fix console total progress bar when using txt2img_upscale

note commit parse_generation_parameters skip_fields from

example
first pass of 2 images
image
select 1st image (not counting the grid) for hr pass (with hr batch count of 3 using my extension)
job finished and and retruns / updates the 1st image with 3 new hr pass images
image


#14645
I made a PR for geninfo from Infotexts (the sutff below)
PR #14645 will merge in order for the multiple image returning to work, otherwise when saving or retrieving seed info will be wrong

Request

can connect_reuse_seed() be be changed to fetch information from elem_id=f'generation_info_{self.tabname}' to f'html_info_{self.script.tabname} parse the info text as opposed the hidden json

def connect_reuse_seed(seed: gr.Number, reuse_seed: gr.Button, generation_info: gr.Textbox, is_subseed):
""" Connects a 'reuse (sub)seed' button's click event so that it copies last used
(sub)seed value from generation info the to the seed field. If copying subseed and subseed strength
was 0, i.e. no variation seed was used, it copies the normal seed value instead."""

example can be seen with what I did in my extension
https://github.com/w-e-w/sd-webui-hires-fix-tweaks/blob/3f9254ffb2d49f52e80989737dbb8c3bdbce445f/hires_fix_tweaks/ui.py#L13-L28
the reason being that remove the need of updating all the other geninfo parameters to just updateing the infotext
when an extension wishes to return extra images

otherwise the following code (and possibly some more logic) needs to be added too the PR too make
allowe to return multiple images properly work

            geninfo["all_prompts"][gallery_index: gallery_index + 1] = processed.all_prompts
            geninfo["all_negative_prompts"][gallery_index: gallery_index + 1] = processed.all_negative_prompts
            geninfo["all_seeds"][gallery_index: gallery_index + 1] = processed.all_seeds
            geninfo["all_subseeds"][gallery_index: gallery_index + 1] = processed.all_subseeds

I believe this simplification applies to not just my extension
and I don't really see advantage of doing it the current way with the hidden json
I can make a PR if you agree, if you don't then this PR probably needs the above code added

Checklist:

@w-e-w w-e-w requested a review from AUTOMATIC1111 as a code owner January 11, 2024 17:49
@AUTOMATIC1111
Copy link
Owner

AUTOMATIC1111 commented Jan 12, 2024

On my side it doesn't serve black images already - it updates the gallery.

As for save_images_before_highres_fix - This can be enabled through p.override_settings.

As for returning multiple images - this kind of breaks geninfo, and it's used, among other things, to show the correct infotext when you click on an image in gallery.

@w-e-w
Copy link
Collaborator Author

w-e-w commented Jan 12, 2024

strange
because on my side black images are returned and the gallery cannot be used again

2024-01-12.16_31_31_911.chrome.mp4

p.override_settings totally forgot about is usable here


yes I know there are other things that use gen info
but that's what exactly I mean there are too many things that are used in general in strange ways
so what are we suggesting is simplifying things to just use geninfo["infotexts"]
it's easier to update one object as opposed to multiple different ones used in different ways have different indexing methods
as far as I know only record information can be parsed from infotexts so I don't really see a point of having it fragmented

no need of having a separate fields thing reuse seed form geninfo["all_seeds"]
if only geninfo["infotexts"]
I've seen a couple of extensions that return incorrect infotext because updating is cumbersome

@w-e-w
Copy link
Collaborator Author

w-e-w commented Jan 12, 2024

seems to have found the fix for the black image issue
the timestamp after ? needs to be stripted
image
fake_image.already_saved_as, _, _ = image["name"].partition('?')

otherwise the check file not found

def save_pil_to_file(self, pil_image, dir=None, format="png"):
already_saved_as = getattr(pil_image, 'already_saved_as', None)
if already_saved_as and os.path.isfile(already_saved_as):
register_tmp_file(shared.demo, already_saved_as)

I guess you have shared.opts.save_images_add_number enabled and so don;t have this issue

@AUTOMATIC1111
Copy link
Owner

Ah. That's a bug. I'll try and fix that.

@w-e-w
Copy link
Collaborator Author

w-e-w commented Jan 12, 2024

the timestamp after ? needs to be stripted

I got upcoming commits to fix the bug

@w-e-w w-e-w marked this pull request as draft January 12, 2024 14:43
@w-e-w w-e-w mentioned this pull request Jan 14, 2024
4 tasks
@w-e-w w-e-w marked this pull request as ready for review January 14, 2024 09:18
@w-e-w w-e-w force-pushed the hr-button-fix branch 2 times, most recently from 96e3a8b to 02bd625 Compare January 16, 2024 14:00
@AUTOMATIC1111 AUTOMATIC1111 merged commit 5df56b3 into dev Jan 20, 2024
6 checks passed
@AUTOMATIC1111 AUTOMATIC1111 deleted the hr-button-fix branch January 20, 2024 07:25
@w-e-w w-e-w mentioned this pull request Feb 17, 2024
@pawel665j pawel665j mentioned this pull request Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants