AlUlkesh / sd_save_intermediate_images

Save intermediate images during the sampling process
The Unlicense
110 stars 17 forks source link

Adding external live preview #41

Closed heloess closed 2 months ago

heloess commented 2 months ago

Added external live preview button that opens a HTML file on browser tab which shows intermediates images and final image sequentially while generating. When save intermediates image and also save final tick button is active, they also save images temporarily to scripts folder as saved.png for HTML file to show them.

Instead of sticking to the other two tick buttons, I attempted add a new button as "Enable external preview" that only temporarily save the images as saved.png to the scripts folder, but I couldn't figure it out. It would be great if someone could add this.

https://github.com/AlUlkesh/sd_save_intermediate_images/assets/96503452/5506ab5f-1ebb-47b2-882c-c75476110cbc

AlUlkesh commented 2 months ago

Hi, very nice idea. Thank you.

A few remarks:

  1. I think the new button should be inside the extension's accordion:

image

  1. The new button is active at all times. So if you press it and there is no saved.png yet, strange things happen.

  2. Wouldn't it make handling easier if the Viewer is openend in a new window instead of a new tab?

  3. I'd prefer it, if the html and the saved.png are in a new subdirectory. For example:

os.path.join(scripts.basedir(), "viewer", "saved.png")

Instead of sticking to the other two tick buttons, I attempted add a new button as "Enable external preview" that only temporarily save the images as saved.png to the scripts folder, but I couldn't figure it out. It would be great if someone could add this.

Wouldn't it work, if you take this out of the IF block?

image

heloess commented 2 months ago

Viewer button is inside in accordion now, fixed HTML file to prevent refresh image if saved.png not found, HTML file opens as window, HTML file and saved.png is in viewer folder.

I take out my code from if statement on def handle_image_saved function, and now it copy final image temporarily even "Also save final image with intermediates" is not enabled. When click on the image viewer, it shows the final image no matter what. It works as desired.

What I'm trying to do now is to add a tick button called "Enable live preview on image viewer" next to the Image viewer button, which temporarily copies the intermediate images to the viewer folder only, without relying on the "save intermediate images" button. However, since this intermediate image saving process depends on the def callback_state(self, d): function under the if ssii_is_active: statement, I could not figure out how to make it independent from the "save intermediate image" tick button.

Edit: I added a check button that named ssii_live_preview, added it if statement below def process as if ssii_is_active or ssii_live_preview:. It basicly doing same thing as ssii_is_active. I struggled to make the button only save saved.png into the viewer folder because def callback_statehas a lot of condition. It still save intermediate images alongside.

AlUlkesh commented 2 months ago

Looks good to me! Thank you. Can you add viewer\saved.png to .gitignore? Then I'll merge it.