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

Auto re-open selected image in gallery when re-generation #2645

Merged
merged 6 commits into from
Oct 15, 2022

Conversation

ruocaled
Copy link
Contributor

@ruocaled ruocaled commented Oct 14, 2022

Fix #2326 #2398 #2445

As above tickets reported, after bump version to gradio 3.4.1(d7474a5), selected image no longer stays selected when you re-generate an image. Every thing is reset to small thumbnail mode in gallery, making re-touch image multiple times a pain.

It is not clear to me if it's a gradio bug or intended. A javascript walkaround on webui might be best approach for now.

How it works

This PR attaches an observer to gallery when generation in progress

  • if there was an image selected in gallery and gradio closes the image after re-generation, auto re-open new result at the previous index after generation.
  • If no image is selected, nothing happens.

This matches behavior of prior to Gradio 3.4.1 version bump. Because it's done with observer, user should not notice the preview window ever being closed.

single image:

chrome_2022-10-14_17-14-06

multiple images:
chrome_2022-10-14_17-14-43

attach an observer of gallery when generation in progress, if there was a image selected in gallery and gallery has only 1 image, auto re-select/open that image.

This matches behavior of prior to Gradio 3.4.1 version bump, is a quality of life feature many people enjoyed.
@EliEron
Copy link

EliEron commented Oct 14, 2022

If there are multiple images in gallery, it goes back to thumbnail mode after re-generation.

That doesn't actually match the old behavior, if you had multiple images in the gallery then Gradio would re-open the image with the same index.

In other words if you had the second image selected and generated another batch, Gradio would automatically open the second image in the new batch of images. This did feel somewhat odd to me, opening the first image in the batch would have felt a bit more intuitive, but regardless that is how it used to function.

Example:
zlo5C4SIU0

@dfaker dfaker added the bug Report of a confirmed bug label Oct 14, 2022
@ruocaled
Copy link
Contributor Author

ruocaled commented Oct 15, 2022

@EliEron This does make me thinking gradio's change is intentional. In older version, If you selected index 1 in a 2 images batch and change batch size to 1 and re-generate, the preview window will broke due to out of index.

However, I did change the code to make it match old behavior (apart from the out of index one), I don't see how it's useful but maybe some people are used to it.

@EliEron
Copy link

EliEron commented Oct 15, 2022

This does make me thinking gradio's change is intentional. In older version, If you selected index 1 in a 2 images batch and change batch size to 1 and re-generate, the preview window will broke due to out of index.

Yeah I did run into that occasionally, but disabling the persistent gallery state all together feels like a blunt way to fix that issue from Gradio's side. Resetting to the first index or closing it as you do would make more sense to me.

I don't see how it's useful but maybe some people are used to it.

That person would be me, hence why I brought it up 😁.

I mostly find it useful because I nearly always do multiple batches, and thus would constantly have to reopen the preview if it returned to thumbnails each time. Also when you are keeping a specific seed and want to quickly see the effect of changing a specific property then being able to look at the preview as it changes from one batch to the next is pretty convenient.

Thank you for matching the old behavior, I appreciate it 👍 .

@AUTOMATIC1111
Copy link
Owner

that is a very, very nice PR

@AUTOMATIC1111 AUTOMATIC1111 merged commit 661a619 into AUTOMATIC1111:master Oct 15, 2022
@DarkAlchy
Copy link

Thanks for this, but for me I will simply ignore all future updates until Automatic1111 says it has been properly fixed (by gradio?).

@DarkAlchy
Copy link

bump gradio to 3.5

Did gradio to 3.5 fix this issue?

@whatever32434144
Copy link

Did gradio to 3.5 fix this issue?

I don't think so.
With the latest version the normal txt2img zoom is working, but stuff like inpaint isn't and still resets the zoom.
I went back to gradio-3.4b3 again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report of a confirmed bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media Viewer keeps minimizing the image after finishing job
6 participants