mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-03 19:02:27 +00:00
Add process_before_every_sampling hook
This commit is contained in:
@@ -187,6 +187,13 @@ class Script:
|
||||
"""
|
||||
pass
|
||||
|
||||
def process_before_every_sampling(self, p, *args, **kwargs):
|
||||
"""
|
||||
Similar to process(), called before every sampling.
|
||||
If you use high-res fix, this will be called two times.
|
||||
"""
|
||||
pass
|
||||
|
||||
def process_batch(self, p, *args, **kwargs):
|
||||
"""
|
||||
Same as process(), but called for every batch.
|
||||
@@ -826,6 +833,14 @@ class ScriptRunner:
|
||||
except Exception:
|
||||
errors.report(f"Error running process: {script.filename}", exc_info=True)
|
||||
|
||||
def process_before_every_sampling(self, p, **kwargs):
|
||||
for script in self.ordered_scripts('process_before_every_sampling'):
|
||||
try:
|
||||
script_args = p.script_args[script.args_from:script.args_to]
|
||||
script.process_before_every_sampling(p, *script_args, **kwargs)
|
||||
except Exception:
|
||||
errors.report(f"Error running process_before_every_sampling: {script.filename}", exc_info=True)
|
||||
|
||||
def before_process_batch(self, p, **kwargs):
|
||||
for script in self.ordered_scripts('before_process_batch'):
|
||||
try:
|
||||
|
Reference in New Issue
Block a user