diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-02-19 09:41:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-19 09:41:29 +0000 |
commit | dfb3b8f398239876cdfc03657680e50c76a1fed8 (patch) | |
tree | 30b5b4e5a179e9d88e75ac0abdcf0090e1c74397 /modules/script_callbacks.py | |
parent | edb10092de516dda5271130ed53628387780a859 (diff) | |
parent | 43137773227344dd79b56c227dbc9fb54ac7c337 (diff) | |
download | stable-diffusion-webui-gfx803-dfb3b8f398239876cdfc03657680e50c76a1fed8.tar.gz stable-diffusion-webui-gfx803-dfb3b8f398239876cdfc03657680e50c76a1fed8.tar.bz2 stable-diffusion-webui-gfx803-dfb3b8f398239876cdfc03657680e50c76a1fed8.zip |
Merge branch 'master' into weighted-learning
Diffstat (limited to 'modules/script_callbacks.py')
-rw-r--r-- | modules/script_callbacks.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/modules/script_callbacks.py b/modules/script_callbacks.py index 4bb45ec7..edd0e2a7 100644 --- a/modules/script_callbacks.py +++ b/modules/script_callbacks.py @@ -46,6 +46,18 @@ class CFGDenoiserParams: """Total number of sampling steps planned"""
+class CFGDenoisedParams:
+ def __init__(self, x, sampling_step, total_sampling_steps):
+ self.x = x
+ """Latent image representation in the process of being denoised"""
+
+ self.sampling_step = sampling_step
+ """Current Sampling step number"""
+
+ self.total_sampling_steps = total_sampling_steps
+ """Total number of sampling steps planned"""
+
+
class UiTrainTabParams:
def __init__(self, txt2img_preview_params):
self.txt2img_preview_params = txt2img_preview_params
@@ -68,6 +80,7 @@ callback_map = dict( callbacks_before_image_saved=[],
callbacks_image_saved=[],
callbacks_cfg_denoiser=[],
+ callbacks_cfg_denoised=[],
callbacks_before_component=[],
callbacks_after_component=[],
callbacks_image_grid=[],
@@ -150,6 +163,14 @@ def cfg_denoiser_callback(params: CFGDenoiserParams): report_exception(c, 'cfg_denoiser_callback')
+def cfg_denoised_callback(params: CFGDenoisedParams):
+ for c in callback_map['callbacks_cfg_denoised']:
+ try:
+ c.callback(params)
+ except Exception:
+ report_exception(c, 'cfg_denoised_callback')
+
+
def before_component_callback(component, **kwargs):
for c in callback_map['callbacks_before_component']:
try:
@@ -283,6 +304,14 @@ def on_cfg_denoiser(callback): add_callback(callback_map['callbacks_cfg_denoiser'], callback)
+def on_cfg_denoised(callback):
+ """register a function to be called in the kdiffussion cfg_denoiser method after building the inner model inputs.
+ The callback is called with one argument:
+ - params: CFGDenoisedParams - parameters to be passed to the inner model and sampling state details.
+ """
+ add_callback(callback_map['callbacks_cfg_denoised'], callback)
+
+
def on_before_component(callback):
"""register a function to be called before a component is created.
The callback is called with arguments:
|