diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-03-11 11:33:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-11 11:33:38 +0000 |
commit | da3f942ab2171e11adf47cd21182db644b9c400a (patch) | |
tree | 195ee0c27ce6fdb54146b91eb070f26294443cd7 /modules/scripts.py | |
parent | aaa367e35ce4e823219c2954ca141ca1ed14800e (diff) | |
parent | a2d635ad135241a0a40f67f7e1638c9c8a4ded04 (diff) | |
download | stable-diffusion-webui-gfx803-da3f942ab2171e11adf47cd21182db644b9c400a.tar.gz stable-diffusion-webui-gfx803-da3f942ab2171e11adf47cd21182db644b9c400a.tar.bz2 stable-diffusion-webui-gfx803-da3f942ab2171e11adf47cd21182db644b9c400a.zip |
Merge pull request #8017 from space-nuko/before-process-batch
Add `before_process_batch` script callback
Diffstat (limited to 'modules/scripts.py')
-rw-r--r-- | modules/scripts.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/scripts.py b/modules/scripts.py index 24056a12..e6a505b3 100644 --- a/modules/scripts.py +++ b/modules/scripts.py @@ -80,6 +80,20 @@ class Script: pass
+ def before_process_batch(self, p, *args, **kwargs):
+ """
+ Called before extra networks are parsed from the prompt, so you can add
+ new extra network keywords to the prompt with this callback.
+
+ **kwargs will have those items:
+ - batch_number - index of current batch, from 0 to number of batches-1
+ - prompts - list of prompts for current batch; you can change contents of this list but changing the number of entries will likely break things
+ - seeds - list of seeds for current batch
+ - subseeds - list of subseeds for current batch
+ """
+
+ pass
+
def process_batch(self, p, *args, **kwargs):
"""
Same as process(), but called for every batch.
@@ -388,6 +402,15 @@ class ScriptRunner: print(f"Error running process: {script.filename}", file=sys.stderr)
print(traceback.format_exc(), file=sys.stderr)
+ def before_process_batch(self, p, **kwargs):
+ for script in self.alwayson_scripts:
+ try:
+ script_args = p.script_args[script.args_from:script.args_to]
+ script.before_process_batch(p, *script_args, **kwargs)
+ except Exception:
+ print(f"Error running before_process_batch: {script.filename}", file=sys.stderr)
+ print(traceback.format_exc(), file=sys.stderr)
+
def process_batch(self, p, **kwargs):
for script in self.alwayson_scripts:
try:
|