mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-04-26 14:59:03 +08:00
fix broken XYZ plot seeds
add new callback for scripts to be used before processing
This commit is contained in:
parent
3163d1269a
commit
f093c9d39d
@ -152,7 +152,9 @@ class StableDiffusionProcessing:
|
|||||||
token_merging_ratio_hr = 0
|
token_merging_ratio_hr = 0
|
||||||
disable_extra_networks: bool = False
|
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_uc = [None, None]
|
||||||
cached_c = [None, None]
|
cached_c = [None, None]
|
||||||
@ -171,7 +173,6 @@ class StableDiffusionProcessing:
|
|||||||
step_multiplier: int = field(default=1, init=False)
|
step_multiplier: int = field(default=1, init=False)
|
||||||
color_corrections: list = field(default=None, 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_prompts: list = field(default=None, init=False)
|
||||||
all_negative_prompts: list = field(default=None, init=False)
|
all_negative_prompts: list = field(default=None, init=False)
|
||||||
all_seeds: 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):
|
def sd_model(self, value):
|
||||||
pass
|
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):
|
def comment(self, text):
|
||||||
self.comments[text] = 1
|
self.comments[text] = 1
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class ScriptSeed(scripts.ScriptBuiltin):
|
|||||||
|
|
||||||
return self.seed, subseed, subseed_strength
|
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
|
p.seed = seed
|
||||||
|
|
||||||
if subseed_strength > 0:
|
if subseed_strength > 0:
|
||||||
|
@ -106,9 +106,16 @@ class Script:
|
|||||||
|
|
||||||
pass
|
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):
|
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.
|
You can modify the processing object (p) here, inject hooks, etc.
|
||||||
args contains all values returned by components from ui()
|
args contains all values returned by components from ui()
|
||||||
"""
|
"""
|
||||||
@ -706,6 +713,14 @@ class ScriptRunner:
|
|||||||
except Exception:
|
except Exception:
|
||||||
errors.report(f"Error running before_hr: {script.filename}", exc_info=True)
|
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_txt2img: ScriptRunner = None
|
||||||
scripts_img2img: ScriptRunner = None
|
scripts_img2img: ScriptRunner = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user