diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-11-04 08:07:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-04 08:07:05 +0000 |
commit | c250d2a08f9c379e3f46de30d975b86376a22aec (patch) | |
tree | 159b69093e4a08e47326ca6af9e473b3551d34da | |
parent | 1b9faaa1c304cd75080d1453a5cb26b02bbdb541 (diff) | |
parent | de64146ad2fc2030a4cd3545676f9e18c93b8b18 (diff) | |
download | stable-diffusion-webui-gfx803-c250d2a08f9c379e3f46de30d975b86376a22aec.tar.gz stable-diffusion-webui-gfx803-c250d2a08f9c379e3f46de30d975b86376a22aec.tar.bz2 stable-diffusion-webui-gfx803-c250d2a08f9c379e3f46de30d975b86376a22aec.zip |
Merge pull request #4182 from macrosoft/process_one
Process one
-rw-r--r-- | modules/processing.py | 3 | ||||
-rw-r--r-- | modules/scripts.py | 16 |
2 files changed, 19 insertions, 0 deletions
diff --git a/modules/processing.py b/modules/processing.py index 7a2fc218..e20d8fc4 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -501,6 +501,9 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: if len(prompts) == 0:
break
+ if p.scripts is not None:
+ p.scripts.process_one(p, n)
+
with devices.autocast():
uc = prompt_parser.get_learned_conditioning(shared.sd_model, len(prompts) * [p.negative_prompt], p.steps)
c = prompt_parser.get_multicond_learned_conditioning(shared.sd_model, prompts, p.steps)
diff --git a/modules/scripts.py b/modules/scripts.py index 28ce07f4..75e47cd2 100644 --- a/modules/scripts.py +++ b/modules/scripts.py @@ -73,6 +73,13 @@ class Script: pass
+ def process_one(self, p, n, *args):
+ """
+ Same as process(), but called for every iteration
+ """
+
+ pass
+
def postprocess(self, p, processed, *args):
"""
This function is called after processing ends for AlwaysVisible scripts.
@@ -296,6 +303,15 @@ class ScriptRunner: print(f"Error running process: {script.filename}", file=sys.stderr)
print(traceback.format_exc(), file=sys.stderr)
+ def process_one(self, p, n):
+ for script in self.alwayson_scripts:
+ try:
+ script_args = p.script_args[script.args_from:script.args_to]
+ script.process_one(p, n, *script_args)
+ except Exception:
+ print(f"Error running process_one: {script.filename}", file=sys.stderr)
+ print(traceback.format_exc(), file=sys.stderr)
+
def postprocess(self, p, processed):
for script in self.alwayson_scripts:
try:
|