aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2024-01-01 16:50:59 +0300
committerAUTOMATIC1111 <16777216c@gmail.com>2024-01-01 16:50:59 +0300
commit0aa7c53c0b9469849377aff83f43c9f75c19b3fa (patch)
tree8fddf13dd7d98d1ae8615e7c216558170203876b /modules
parent2a7ad70db5447dd1d5915b2b59715ee74f670119 (diff)
fix borked merge, rename fields to better match what they do, change setting default to true for #13653
Diffstat (limited to 'modules')
-rw-r--r--modules/call_queue.py2
-rw-r--r--modules/img2img.py2
-rw-r--r--modules/processing.py2
-rw-r--r--modules/shared_options.py2
-rw-r--r--modules/shared_state.py12
-rw-r--r--modules/ui_toprow.py8
6 files changed, 17 insertions, 11 deletions
diff --git a/modules/call_queue.py b/modules/call_queue.py
index 01c6d17f..bcd7c546 100644
--- a/modules/call_queue.py
+++ b/modules/call_queue.py
@@ -78,7 +78,7 @@ def wrap_gradio_call(func, extra_outputs=None, add_stats=False):
shared.state.skipped = False
shared.state.interrupted = False
- shared.state.interrupted_next = False
+ shared.state.stopping_generation = False
shared.state.job_count = 0
if not add_stats:
diff --git a/modules/img2img.py b/modules/img2img.py
index 829faa81..e7e8e251 100644
--- a/modules/img2img.py
+++ b/modules/img2img.py
@@ -51,7 +51,7 @@ def process_batch(p, input_dir, output_dir, inpaint_mask_dir, args, to_scale=Fal
if state.skipped:
state.skipped = False
- if state.interrupted or state.interrupted_next:
+ if state.interrupted or state.stopping_generation:
break
try:
diff --git a/modules/processing.py b/modules/processing.py
index 00de2ed2..f55b85ed 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -865,7 +865,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
if state.skipped:
state.skipped = False
- if state.interrupted or state.interrupted_next:
+ if state.interrupted or state.stopping_generation:
break
sd_models.reload_model_weights() # model can be changed for example by refiner
diff --git a/modules/shared_options.py b/modules/shared_options.py
index 7852e0ea..7581e276 100644
--- a/modules/shared_options.py
+++ b/modules/shared_options.py
@@ -120,7 +120,6 @@ options_templates.update(options_section(('system', "System", "system"), {
"disable_mmap_load_safetensors": OptionInfo(False, "Disable memmapping for loading .safetensors files.").info("fixes very slow loading speed in some cases"),
"hide_ldm_prints": OptionInfo(True, "Prevent Stability-AI's ldm/sgm modules from printing noise to console."),
"dump_stacks_on_signal": OptionInfo(False, "Print stack traces before exiting the program with ctrl+c."),
- "interrupt_after_current": OptionInfo(False, "Interrupt generation after current image is finished on batch processing"),
}))
options_templates.update(options_section(('API', "API", "system"), {
@@ -286,6 +285,7 @@ options_templates.update(options_section(('ui_alternatives', "UI alternatives",
"hires_fix_show_prompts": OptionInfo(False, "Hires fix: show hires prompt and negative prompt").needs_reload_ui(),
"txt2img_settings_accordion": OptionInfo(False, "Settings in txt2img hidden under Accordion").needs_reload_ui(),
"img2img_settings_accordion": OptionInfo(False, "Settings in img2img hidden under Accordion").needs_reload_ui(),
+ "interrupt_after_current": OptionInfo(True, "Don't Interrupt in the middle").info("when using Interrupt button, if generating more than one image, stop after the generation of an image has finished, instead of immediately"),
}))
options_templates.update(options_section(('ui', "User interface", "ui"), {
diff --git a/modules/shared_state.py b/modules/shared_state.py
index 532fdcd8..33996691 100644
--- a/modules/shared_state.py
+++ b/modules/shared_state.py
@@ -12,7 +12,7 @@ log = logging.getLogger(__name__)
class State:
skipped = False
interrupted = False
- interrupted_next = False
+ stopping_generation = False
job = ""
job_no = 0
job_count = 0
@@ -80,9 +80,9 @@ class State:
self.interrupted = True
log.info("Received interrupt request")
- def interrupt_next(self):
- self.interrupted_next = True
- log.info("Received interrupt request, interrupt after current job")
+ def stop_generating(self):
+ self.stopping_generation = True
+ log.info("Received stop generating request")
def nextjob(self):
if shared.opts.live_previews_enable and shared.opts.show_progress_every_n_steps == -1:
@@ -96,7 +96,7 @@ class State:
obj = {
"skipped": self.skipped,
"interrupted": self.interrupted,
- "interrupted_next": self.interrupted_next,
+ "stopping_generation": self.stopping_generation,
"job": self.job,
"job_count": self.job_count,
"job_timestamp": self.job_timestamp,
@@ -120,7 +120,7 @@ class State:
self.id_live_preview = 0
self.skipped = False
self.interrupted = False
- self.interrupted_next = False
+ self.stopping_generation = False
self.textinfo = None
self.job = job
devices.torch_gc()
diff --git a/modules/ui_toprow.py b/modules/ui_toprow.py
index 9caf8faa..1abc9117 100644
--- a/modules/ui_toprow.py
+++ b/modules/ui_toprow.py
@@ -106,8 +106,14 @@ class Toprow:
outputs=[],
)
+ def interrupt_function():
+ if shared.state.job_count > 1 and shared.opts.interrupt_after_current:
+ shared.state.stop_generating()
+ else:
+ shared.state.interrupt()
+
self.interrupt.click(
- fn=lambda: shared.state.interrupt(),
+ fn=interrupt_function,
inputs=[],
outputs=[],
)