stable-diffusion-webui
stable-diffusion-webui copied to clipboard
Add save_intermediate_images script
Combines a few different scripts in various GitHub issues with some useful added features:
- This script is set to
scripts.AlwaysVisible
, meaning it can be run in combination with other scripts - Intermediate images are saved using the same filename structure as the final images, in a subdirectory called "intermediates". The custom script in the wiki overwrites your intermediate images each time you generate new images
- Allows you to save every N images (defaults to 5)
- Allows you to save either denoised or noisy intermediate images
See #1026 See #2137 See #2094 See #2739 See #4709
very nice but this will have to become an extension
This is a very useful functionality! I'm not sure if this is currently being converted to an extension, but if so I think there is a small bug in the current code. This:
save_image(image, os.path.join(p.outpath_samples, "intermediates"), f"{current_step:02}", seed=p.seed, p=p)
gives me filenames like 15-0000-4092713123.0-[prompt_spaces].png
I believe this would solve the issue:
save_image(image, os.path.join(p.outpath_samples, "intermediates"), f"{current_step:02}", seed=p.seed, prompt=p.prompt, p=p)
I put Kevin's work into an extension and made a few changes:
- put the UI in an Accordion
- save all intermediates into their own subdirectory
- include the prompt in the filename
Any thoughts?
https://github.com/AlUlkesh/sd_save_intermediate_images
https://github.com/AlUlkesh/sd_save_intermediate_images
usefully. seems there's no export with ddim sampler. is it ok or just for me?
Any thoughts?
how about intermediate subfolder names correspond to index number of currently generated image instead of a sequence from zero? like xxxxx.image-filename-pattern-from-settings. => xxxxxx folder. or more odd way "last generated index number"+1 if there's no way to accure current number.
include the prompt in the filename
large prompts cropped and mostly useless, especially for large path. how about determine name from settings instead?
Good suggestions, thanks.
Turns out DDIM and PLMS use VanillaStableDiffusionSampler, while the others use KDiffusionSampler. It looks like VanillaStableDiffusionSampler doesn't have callback-capabilities, so I'm not sure it's possible.
I'll look into them.
Update: Since the number-prefix of the final file is not determined before saving it, I'm repeating the logic in my script now. This is for filenames and folder names. That should make it a lot easier to correlate the immediate with the final image.
it is now an extension: https://github.com/AlUlkesh/sd_save_intermediate_images
Plz add API support to this extension