Skip to content

Commit 9182dd7

Browse files
Merge pull request #12634 from catboxanon/feat/live-preview-fast-interrupt
Improve interrupt speed
2 parents f739e3e + 9d1d63a commit 9182dd7

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

modules/processing.py

+3
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,9 @@ def sample(self, conditioning, unconditional_conditioning, seeds, subseeds, subs
11551155
devices.torch_gc()
11561156

11571157
def sample_hr_pass(self, samples, decoded_samples, seeds, subseeds, subseed_strength, prompts):
1158+
if shared.state.interrupted:
1159+
return samples
1160+
11581161
self.is_hr_pass = True
11591162

11601163
target_width = self.hr_upscale_to_x

modules/sd_samplers_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def setup_img2img_steps(p, steps=None):
3636

3737
def samples_to_images_tensor(sample, approximation=None, model=None):
3838
'''latents -> images [-1, 1]'''
39-
if approximation is None:
39+
if approximation is None or (shared.state.interrupted and opts.live_preview_fast_interrupt):
4040
approximation = approximation_indexes.get(opts.show_progress_type, 0)
4141

4242
if approximation == 2:

modules/shared_options.py

+1
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@
281281
"show_progress_type": OptionInfo("Approx NN", "Live preview method", gr.Radio, {"choices": ["Full", "Approx NN", "Approx cheap", "TAESD"]}).info("Full = slow but pretty; Approx NN and TAESD = fast but low quality; Approx cheap = super fast but terrible otherwise"),
282282
"live_preview_content": OptionInfo("Prompt", "Live preview subject", gr.Radio, {"choices": ["Combined", "Prompt", "Negative prompt"]}),
283283
"live_preview_refresh_period": OptionInfo(1000, "Progressbar and preview update period").info("in milliseconds"),
284+
"live_preview_fast_interrupt": OptionInfo(False, "Return image with chosen live preview method on interrupt").info("makes interrupts faster"),
284285
}))
285286

286287
options_templates.update(options_section(('sampler-params', "Sampler parameters"), {

0 commit comments

Comments
 (0)