diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-11-02 09:12:32 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-11-02 09:12:32 +0000 |
commit | 4a8cf01f6f7f072cc9c67d6b31662384b212dd9c (patch) | |
tree | 2d9cf416afbff669f3aef3bfcaa11a7803e75bba | |
parent | e526f6b378e908d0a4a15661aaa1f67ecbaef1ff (diff) | |
download | stable-diffusion-webui-gfx803-4a8cf01f6f7f072cc9c67d6b31662384b212dd9c.tar.gz stable-diffusion-webui-gfx803-4a8cf01f6f7f072cc9c67d6b31662384b212dd9c.tar.bz2 stable-diffusion-webui-gfx803-4a8cf01f6f7f072cc9c67d6b31662384b212dd9c.zip |
remove duplicate code from #3970
-rw-r--r-- | modules/api/api.py | 10 | ||||
-rw-r--r-- | modules/shared.py | 14 | ||||
-rw-r--r-- | modules/ui.py | 10 |
3 files changed, 16 insertions, 18 deletions
diff --git a/modules/api/api.py b/modules/api/api.py index b3d85e46..71c9c160 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -178,15 +178,7 @@ class Api: progress = min(progress, 1) - # copy from check_progress_call of ui.py - - if shared.parallel_processing_allowed: - if shared.state.sampling_step - shared.state.current_image_sampling_step >= shared.opts.show_progress_every_n_steps and shared.state.current_latent is not None: - if shared.opts.show_progress_grid: - shared.state.current_image = samples_to_image_grid(shared.state.current_latent) - else: - shared.state.current_image = sample_to_image(shared.state.current_latent) - shared.state.current_image_sampling_step = shared.state.sampling_step + shared.state.set_current_image() current_image = None if shared.state.current_image and not req.skip_current_image: diff --git a/modules/shared.py b/modules/shared.py index 04aaa648..e65f6080 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -184,6 +184,20 @@ class State: devices.torch_gc()
+ """sets self.current_image from self.current_latent if enough sampling steps have been made after the last call to this"""
+ def set_current_image(self):
+ if not parallel_processing_allowed:
+ return
+
+ if self.sampling_step - self.current_image_sampling_step >= opts.show_progress_every_n_steps and self.current_latent is not None:
+ if opts.show_progress_grid:
+ self.current_image = sd_samplers.samples_to_image_grid(self.current_latent)
+ else:
+ self.current_image = sd_samplers.sample_to_image(self.current_latent)
+
+ self.current_image_sampling_step = self.sampling_step
+
+
state = State()
artist_db = modules.artists.ArtistsDatabase(os.path.join(script_path, 'artists.csv'))
diff --git a/modules/ui.py b/modules/ui.py index 45cd8c3f..784439ba 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -277,15 +277,7 @@ def check_progress_call(id_part): preview_visibility = gr_show(False)
if opts.show_progress_every_n_steps > 0:
- if shared.parallel_processing_allowed:
-
- if shared.state.sampling_step - shared.state.current_image_sampling_step >= opts.show_progress_every_n_steps and shared.state.current_latent is not None:
- if opts.show_progress_grid:
- shared.state.current_image = modules.sd_samplers.samples_to_image_grid(shared.state.current_latent)
- else:
- shared.state.current_image = modules.sd_samplers.sample_to_image(shared.state.current_latent)
- shared.state.current_image_sampling_step = shared.state.sampling_step
-
+ shared.state.set_current_image()
image = shared.state.current_image
if image is None:
|