From 938ec5e00a2f0d372d8735648f8e791dfcd873bc Mon Sep 17 00:00:00 2001 From: Haoming Date: Fri, 6 Dec 2024 22:22:13 +0800 Subject: [PATCH] prevent redundant preview --- modules/sd_samplers_common.py | 6 +++++- modules/shared_state.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/sd_samplers_common.py b/modules/sd_samplers_common.py index c060cccb24b..1550300e95f 100644 --- a/modules/sd_samplers_common.py +++ b/modules/sd_samplers_common.py @@ -115,7 +115,11 @@ def images_tensor_to_samples(image, approximation=None, model=None): def store_latent(decoded): state.current_latent = decoded - if opts.live_previews_enable and opts.show_progress_every_n_steps > 0 and shared.state.sampling_step % opts.show_progress_every_n_steps == 0: + if ( + (opts.live_previews_enable and opts.show_progress_every_n_steps > 0) and + (shared.state.sampling_steps - shared.state.sampling_step > opts.show_progress_every_n_steps) and + (shared.state.sampling_step % opts.show_progress_every_n_steps == 0) + ): if not shared.parallel_processing_allowed: shared.state.assign_current_image(sample_to_image(decoded)) diff --git a/modules/shared_state.py b/modules/shared_state.py index 4cd53af6271..74ee11dd6c4 100644 --- a/modules/shared_state.py +++ b/modules/shared_state.py @@ -139,7 +139,11 @@ def set_current_image(self): if not shared.parallel_processing_allowed: return - if self.sampling_step - self.current_image_sampling_step >= shared.opts.show_progress_every_n_steps and shared.opts.live_previews_enable and shared.opts.show_progress_every_n_steps != -1: + if ( + (shared.opts.live_previews_enable and shared.opts.show_progress_every_n_steps != -1) and + (self.sampling_steps - self.sampling_step > shared.opts.show_progress_every_n_steps) and + (self.sampling_step - self.current_image_sampling_step >= shared.opts.show_progress_every_n_steps) + ): self.do_set_current_image() def do_set_current_image(self):