Commit f093c9d3 authored by AUTOMATIC1111's avatar AUTOMATIC1111

fix broken XYZ plot seeds

add new callback for scripts to be used before processing
parent 3163d126
......@@ -152,7 +152,9 @@ class StableDiffusionProcessing:
token_merging_ratio_hr = 0
disable_extra_networks: bool = False
script_args: list = None
scripts_value: scripts.ScriptRunner = field(default=None, init=False)
script_args_value: list = field(default=None, init=False)
scripts_setup_complete: bool = field(default=False, init=False)
cached_uc = [None, None]
cached_c = [None, None]
......@@ -171,7 +173,6 @@ class StableDiffusionProcessing:
step_multiplier: int = field(default=1, init=False)
color_corrections: list = field(default=None, init=False)
scripts: list = field(default=None, init=False)
all_prompts: list = field(default=None, init=False)
all_negative_prompts: list = field(default=None, init=False)
all_seeds: list = field(default=None, init=False)
......@@ -229,6 +230,33 @@ class StableDiffusionProcessing:
def sd_model(self, value):
pass
@property
def scripts(self):
return self.scripts_value
@scripts.setter
def scripts(self, value):
self.scripts_value = value
if self.scripts_value and self.script_args_value and not self.scripts_setup_complete:
self.setup_scripts()
@property
def script_args(self):
return self.script_args_value
@script_args.setter
def script_args(self, value):
self.script_args_value = value
if self.scripts_value and self.script_args_value and not self.scripts_setup_complete:
self.setup_scripts()
def setup_scripts(self):
self.scripts_setup_complete = True
self.scripts.setup_scrips(self)
def comment(self, text):
self.comments[text] = 1
......
......@@ -58,7 +58,7 @@ class ScriptSeed(scripts.ScriptBuiltin):
return self.seed, subseed, subseed_strength
def before_process(self, p, seed, subseed, subseed_strength):
def setup(self, p, seed, subseed, subseed_strength):
p.seed = seed
if subseed_strength > 0:
......
......@@ -106,9 +106,16 @@ class Script:
pass
def setup(self, p, *args):
"""For AlwaysVisible scripts, this function is called when the processing object is set up, before any processing starts.
args contains all values returned by components from ui().
"""
pass
def before_process(self, p, *args):
"""
This function is called very early before processing begins for AlwaysVisible scripts.
This function is called very early during processing begins for AlwaysVisible scripts.
You can modify the processing object (p) here, inject hooks, etc.
args contains all values returned by components from ui()
"""
......@@ -706,6 +713,14 @@ class ScriptRunner:
except Exception:
errors.report(f"Error running before_hr: {script.filename}", exc_info=True)
def setup_scrips(self, p):
for script in self.alwayson_scripts:
try:
script_args = p.script_args[script.args_from:script.args_to]
script.setup(p, *script_args)
except Exception:
errors.report(f"Error running setup: {script.filename}", exc_info=True)
scripts_txt2img: ScriptRunner = None
scripts_img2img: ScriptRunner = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment