AlUlkesh / sd_save_intermediate_images

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

Save the images shown in livePreview #14

Closed wojteksosnowski closed 1 year ago

wojteksosnowski commented 1 year ago

Images saved by the extension are different than those visible in livePreview. Save those instead.

AlUlkesh commented 1 year ago

That shouldn't be the case. Do you haven an example?

wojteksosnowski commented 1 year ago
image

Just as it is in the settings menu. It is very useful in workflows that include inpainting with a mask. These settings give you good interpolation between generated image and masked content.

AlUlkesh commented 1 year ago

Yes, that is exactly how it works for me.

Can you check the "debug" checkbox and post the console log? And perhaps a screenshot of how the preview looks different from the intermediate files?

wojteksosnowski commented 1 year ago

input: cropdom-kredytowy-2x-kopia

mask: 00059-3972346835-analog style illustration warhammer 40k chaos space marine character, standing on a burning battlefield in the background, crumb

from extension:

01354-010-3972346835-analog style illustration warhammer 40k chaos space marine character, standing on a burning battlefield in the background, crumb 01354-008-3972346835-analog style illustration warhammer 40k chaos space marine character, standing on a burning battlefield in the background, crumb 01354-006-3972346835-analog style illustration warhammer 40k chaos space marine character, standing on a burning battlefield in the background, crumb 01354-004-3972346835-analog style illustration warhammer 40k chaos space marine character, standing on a burning battlefield in the background, crumb 01354-002-3972346835-analog style illustration warhammer 40k chaos space marine character, standing on a burning battlefield in the background, crumb

captured from livePreview

download-24 download-23 download-22 download-21 download-20

final: 01354-3972346835-analog style illustration warhammer 40k chaos space marine character, standing on a burning battlefield in the background, crumb

settings: Przechwytywanie zawartości sieci Web_17-1-2023_112756_127 0 0 1

debug: Snipaste_2023-01-17_11-29-09

AlUlkesh commented 1 year ago

Thanks, I can reproduce it now. I'll look into it.

wojteksosnowski commented 1 year ago

That would be awesome. This effect is great for compositing.

AlUlkesh commented 1 year ago

Turns out that function was just implemented 3 days ago: https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/f94a215abed85b34ae978853078812801d3e7738

I put in a new option, that should do the trick: image This now takes the intermediate saves directly from the preview image. While implementing this I ran into aproblem: Since only one image is displayed in the preview, I would end up with repeats of the same image with batch_size > 1. For now I'm falling back to simple "denoised" for images after batch_size > 1.

Let me know, if this does, what you expected.

wojteksosnowski commented 1 year ago

Hey, extension saves the right images from live preview. But if you change n skip to anything else than 5 it crashes.

AlUlkesh commented 1 year ago

Hmm, just tried 1,3,4,6 here and works for me. Can you tick debug again with a crash?

wojteksosnowski commented 1 year ago
image

Przechwytywanie zawartości sieci Web_17-1-2023_22834_127 0 0 1

When I change to 5 it goes through.

AlUlkesh commented 1 year ago

Works for me, with, I think, the same settings. I hate bugs like that...

I'll need the full console log with debug for that, beginning with starting the webui-user, until the error.

venv "automatic\Scripts\Python.exe"
Python 3.10.6 | packaged by conda-forge | (main, Oct  7 2022, 20:14:50) [MSC v.1916 64 bit (AMD64)]
Commit hash: e0e80050091ea7f58ae17c69f31d1b5de5e0ae20
...
wojteksosnowski commented 1 year ago

Well, I am having trouble with recreating it. So maybe it was just a fluke. Is it possible to add an option to save only last N previews?

AlUlkesh commented 1 year ago

Oh, good to hear.

Not really, because with img2img I don't know how many steps there really are, before it's done. It's usually less than the number of steps you input.

I suppose I could delete the first ones again at the end. Would that help?

AlUlkesh commented 1 year ago

I just ran into the bug you had yesterday, For me it was with "save every 2 steps", but because my preview setting was also 2, apparently the preview image was not there yet. I'll change it in the next commit, to not try to process when there's no image.