diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-01-01 15:31:01 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-01 15:31:01 +0000 |
commit | 6062c85d4d71fa2d1eef864490f1359b24536bbe (patch) | |
tree | fac245edf8b7f23aa57eaeb48ff40c5a8b3dd614 /modules/script_callbacks.py | |
parent | 524d532b387732d4d32f237e792c7f201a934400 (diff) | |
parent | 5f12b23b8bb7fca585a3a1e844881d06f171364e (diff) | |
download | stable-diffusion-webui-gfx803-6062c85d4d71fa2d1eef864490f1359b24536bbe.tar.gz stable-diffusion-webui-gfx803-6062c85d4d71fa2d1eef864490f1359b24536bbe.tar.bz2 stable-diffusion-webui-gfx803-6062c85d4d71fa2d1eef864490f1359b24536bbe.zip |
Merge pull request #6094 from AlUlkesh/master
Adding image numbers on grids
Diffstat (limited to 'modules/script_callbacks.py')
-rw-r--r-- | modules/script_callbacks.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/script_callbacks.py b/modules/script_callbacks.py index 8e22f875..0c854407 100644 --- a/modules/script_callbacks.py +++ b/modules/script_callbacks.py @@ -51,6 +51,11 @@ class UiTrainTabParams: self.txt2img_preview_params = txt2img_preview_params
+class ImageGridLoopParams:
+ def __init__(self, img):
+ self.img = img
+
+
ScriptCallback = namedtuple("ScriptCallback", ["script", "callback"])
callback_map = dict(
callbacks_app_started=[],
@@ -63,6 +68,7 @@ callback_map = dict( callbacks_cfg_denoiser=[],
callbacks_before_component=[],
callbacks_after_component=[],
+ callbacks_image_grid_loop=[],
)
@@ -154,6 +160,12 @@ def after_component_callback(component, **kwargs): except Exception:
report_exception(c, 'after_component_callback')
+def image_grid_loop_callback(component, **kwargs):
+ for c in callback_map['callbacks_image_grid_loop']:
+ try:
+ c.callback(component, **kwargs)
+ except Exception:
+ report_exception(c, 'image_grid_loop')
def add_callback(callbacks, fun):
stack = [x for x in inspect.stack() if x.filename != __file__]
@@ -255,3 +267,11 @@ def on_before_component(callback): def on_after_component(callback):
"""register a function to be called after a component is created. See on_before_component for more."""
add_callback(callback_map['callbacks_after_component'], callback)
+
+
+def on_image_grid_loop(callback):
+ """register a function to be called inside the image grid loop.
+ The callback is called with one argument:
+ - params: ImageGridLoopParams - parameters to be used inside the image grid loop.
+ """
+ add_callback(callback_map['callbacks_image_grid_loop'], callback)
|