stable-diffusion.cpp icon indicating copy to clipboard operation
stable-diffusion.cpp copied to clipboard

Image Preview

Open ring-c opened this issue 1 year ago • 4 comments

For big batches, if something went wrong - we are losing all generated images. I want to get images as they a sampled. This way I can save content to disk and/or show preview as it get done.

Its also a step to #354, we can just call a sd_result_cb with additional parameters. This will take time to modify each sample method in sample_k_diffusion() so i do plan to make it as separate PR (if i can get it working).

What do you think about this changes? This PR is not breaking, just replacing functionality if callback is set.

ring-c avatar Sep 20 '24 03:09 ring-c

Well, i added a callback for a sampling steps. Its inefficient, with steps callback: txt2img completed in 64.58s Without: txt2img completed in 18.03s (Euler A, 32 steps)

Can look something like this: Screenshot_20240928_112203

ring-c avatar Sep 28 '24 06:09 ring-c

Well, i added a callback for a sampling steps. Its inefficient, with steps callback: txt2img completed in 64.58s Without: txt2img completed in 18.03s (Euler A, 32 steps)

Can look something like this: Screenshot_20240928_112203

Does the 64.58s include saving the images to disk?

amblamps avatar Sep 28 '24 08:09 amblamps

@amblamps images are saved in this time, but impact is minimal. I will try to test different approaches to minimize times, but most of the time is decode_first_stage call.

ring-c avatar Sep 28 '24 08:09 ring-c

After testing I can confirm that with right callback function, with will not stop execution - everything else is 0 second, except decode_first_stage. It gives 0.8s to 1.0s compute time on my setup, most of the time its 0.82s to 0.86s. This is per decode, mean per step.

ring-c avatar Sep 28 '24 12:09 ring-c

Replaced by https://github.com/leejet/stable-diffusion.cpp/pull/522. However, I still want to express my gratitude for your contribution.

leejet avatar Nov 13 '25 15:11 leejet