Skip to content

Commit f1b6ac6

Browse files
committed
Added option to preview Created images on batch completion.
1 parent 172c4bc commit f1b6ac6

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

modules/shared.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ def interrupt(self):
146146
self.interrupted = True
147147

148148
def nextjob(self):
149+
if opts.show_progress_every_n_steps == -1:
150+
self.do_set_current_image()
151+
149152
self.job_no += 1
150153
self.sampling_step = 0
151154
self.current_image_sampling_step = 0
@@ -186,17 +189,21 @@ def end(self):
186189

187190
"""sets self.current_image from self.current_latent if enough sampling steps have been made after the last call to this"""
188191
def set_current_image(self):
192+
if self.sampling_step - self.current_image_sampling_step >= opts.show_progress_every_n_steps and opts.show_progress_every_n_steps > 0:
193+
self.do_set_current_image()
194+
195+
def do_set_current_image(self):
189196
if not parallel_processing_allowed:
190197
return
198+
if self.current_latent is None:
199+
return
200+
201+
if opts.show_progress_grid:
202+
self.current_image = sd_samplers.samples_to_image_grid(self.current_latent)
203+
else:
204+
self.current_image = sd_samplers.sample_to_image(self.current_latent)
191205

192-
if self.sampling_step - self.current_image_sampling_step >= opts.show_progress_every_n_steps and self.current_latent is not None:
193-
if opts.show_progress_grid:
194-
self.current_image = sd_samplers.samples_to_image_grid(self.current_latent)
195-
else:
196-
self.current_image = sd_samplers.sample_to_image(self.current_latent)
197-
198-
self.current_image_sampling_step = self.sampling_step
199-
206+
self.current_image_sampling_step = self.sampling_step
200207

201208
state = State()
202209

@@ -351,7 +358,7 @@ def options_section(section_identifier, options_dict):
351358

352359
options_templates.update(options_section(('ui', "User interface"), {
353360
"show_progressbar": OptionInfo(True, "Show progressbar"),
354-
"show_progress_every_n_steps": OptionInfo(0, "Show image creation progress every N sampling steps. Set 0 to disable.", gr.Slider, {"minimum": 0, "maximum": 32, "step": 1}),
361+
"show_progress_every_n_steps": OptionInfo(0, "Show image creation progress every N sampling steps. Set to 0 to disable. Set to -1 to show after completion of batch.", gr.Slider, {"minimum": -1, "maximum": 32, "step": 1}),
355362
"show_progress_grid": OptionInfo(True, "Show previews of all images generated in a batch as a grid"),
356363
"return_grid": OptionInfo(True, "Show grid in results for web"),
357364
"do_not_show_images": OptionInfo(False, "Do not show any images in results for web"),

modules/ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def check_progress_call(id_part):
276276
image = gr_show(False)
277277
preview_visibility = gr_show(False)
278278

279-
if opts.show_progress_every_n_steps > 0:
279+
if opts.show_progress_every_n_steps != 0:
280280
shared.state.set_current_image()
281281
image = shared.state.current_image
282282

0 commit comments

Comments
 (0)