merge from upstream

This commit is contained in:
Vladimir Mandic
2023-05-04 07:51:28 -04:00
parent 22090d7bd8
commit 865c0bc7a3
17 changed files with 339 additions and 178 deletions
+14
View File
@@ -110,6 +110,7 @@ callback_map = dict(
callbacks_infotext_pasted=[],
callbacks_script_unloaded=[],
callbacks_before_ui=[],
callbacks_on_reload=[],
)
@@ -126,6 +127,14 @@ def app_started_callback(demo: Optional[Blocks], app: FastAPI):
report_exception(e, c, 'app_started_callback')
def app_reload_callback():
for c in callback_map['callbacks_on_reload']:
try:
c.callback()
except Exception as e:
report_exception(e, c, 'callbacks_on_reload')
def model_loaded_callback(sd_model):
for c in callback_map['callbacks_model_loaded']:
try:
@@ -279,6 +288,11 @@ def on_app_started(callback):
add_callback(callback_map['callbacks_app_started'], callback)
def on_before_reload(callback):
"""register a function to be called just before the server reloads."""
add_callback(callback_map['callbacks_on_reload'], callback)
def on_model_loaded(callback):
"""register a function to be called when the stable diffusion model is created; the model is
passed as an argument; this function is also called when the script is reloaded. """