diff options
author | Vespinian <vespinian@proton.me> | 2023-03-11 17:33:35 +0000 |
---|---|---|
committer | Vespinian <vespinian@proton.me> | 2023-03-11 17:33:35 +0000 |
commit | 46f9fe3cd6b7be712d85cdfc2cdff7ac3fe878b5 (patch) | |
tree | a134b22d856ab534c497b04c0d7ec87935cfcce7 /modules/scripts.py | |
parent | 2174f58daee1e077eec1125e196d34cc93dbaf23 (diff) | |
parent | 94ffa9fc5386e51f20692ab46906135e8de33110 (diff) | |
download | stable-diffusion-webui-gfx803-46f9fe3cd6b7be712d85cdfc2cdff7ac3fe878b5.tar.gz stable-diffusion-webui-gfx803-46f9fe3cd6b7be712d85cdfc2cdff7ac3fe878b5.tar.bz2 stable-diffusion-webui-gfx803-46f9fe3cd6b7be712d85cdfc2cdff7ac3fe878b5.zip |
Merge branch 'master' of https://github.com/AUTOMATIC1111/stable-diffusion-webui
Diffstat (limited to 'modules/scripts.py')
-rw-r--r-- | modules/scripts.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/scripts.py b/modules/scripts.py index 24056a12..8de19884 100644 --- a/modules/scripts.py +++ b/modules/scripts.py @@ -33,6 +33,11 @@ class Script: parsing infotext to set the value for the component; see ui.py's txt2img_paste_fields for an example
"""
+ paste_field_names = None
+ """if set in ui(), this is a list of names of infotext fields; the fields will be sent through the
+ various "Send to <X>" buttons when clicked
+ """
+
def title(self):
"""this function should return the title of the script. This is what will be displayed in the dropdown menu."""
@@ -80,6 +85,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.
@@ -256,6 +275,7 @@ class ScriptRunner: self.alwayson_scripts = []
self.titles = []
self.infotext_fields = []
+ self.paste_field_names = []
def initialize_scripts(self, is_img2img):
from modules import scripts_auto_postprocessing
@@ -304,6 +324,9 @@ class ScriptRunner: if script.infotext_fields is not None:
self.infotext_fields += script.infotext_fields
+ if script.paste_field_names is not None:
+ self.paste_field_names += script.paste_field_names
+
inputs += controls
inputs_alwayson += [script.alwayson for _ in controls]
script.args_to = len(inputs)
@@ -388,6 +411,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:
|