From 2621aecaccd92fa93b4b65a6be2a8e982e37235f Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 29 Sep 2025 19:25:47 -0400 Subject: [PATCH] interrrupt will now show last known preview image Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 2 ++ modules/processing.py | 11 +++++++++-- modules/shared.py | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f73e1bf33..cee8bcb0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,8 @@ - networks ability to filter lora by base model version - **Other** - server will note when restart is recommended due to package updates + - **interrrupt** will now show last known preview image + *keep incomplete* setting is now *save interrupted* - **logging** enable `debug`, `docs` and `api-docs` by default - **ipex** simplify internal implementation - refactor to use new libraries diff --git a/modules/processing.py b/modules/processing.py index e01f88bdc..d42929b23 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -427,13 +427,20 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: for script_image, script_infotext in zip(results.images, results.infotexts): output_images.append(script_image) infotexts.append(script_infotext) + if samples is None: from modules.processing_diffusers import process_diffusers samples = process_diffusers(p) timer.process.record('process') - if not shared.opts.keep_incomplete and shared.state.interrupted: - samples = [] + if shared.state.interrupted: + shared.log.debug(f'Process: batch={n+1}/{p.n_iter} interrupted') + p.do_not_save_samples = not shared.opts.keep_incomplete + if shared.state.current_image is not None and isinstance(shared.state.current_image, Image.Image): + samples = [shared.state.current_image] + infotexts = [create_infotext(p, p.all_prompts, p.all_seeds, p.all_subseeds, index=0)] + else: + samples = [] if p.scripts is not None and isinstance(p.scripts, scripts_manager.ScriptRunner): p.scripts.postprocess_batch(p, samples, batch_number=n) diff --git a/modules/shared.py b/modules/shared.py index d35dc6fbb..fab234f94 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -471,7 +471,7 @@ options_templates.update(options_section(('system-paths', "System Paths"), { options_templates.update(options_section(('saving-images', "Image Options"), { "samples_save": OptionInfo(True, "Save all generated images"), - "keep_incomplete": OptionInfo(True, "Keep incomplete images"), + "keep_incomplete": OptionInfo(True, "Save interrupted images"), "samples_format": OptionInfo('jpg', 'File format', gr.Dropdown, {"choices": ["jpg", "png", "webp", "tiff", "jp2", "jxl"]}), "jpeg_quality": OptionInfo(90, "Image quality", gr.Slider, {"minimum": 1, "maximum": 100, "step": 1}), "img_max_size_mp": OptionInfo(1000, "Maximum image size (MP)", gr.Slider, {"minimum": 100, "maximum": 2000, "step": 1}),