From 8a178e67172f4677cad747b3364db3f2a0636911 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Fri, 19 May 2023 16:00:53 +0300 Subject: [PATCH] Refactor configure opts_onchange out --- webui.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/webui.py b/webui.py index ace38123..53fe260e 100644 --- a/webui.py +++ b/webui.py @@ -190,6 +190,15 @@ def configure_sigint_handler(): signal.signal(signal.SIGINT, sigint_handler) +def configure_opts_onchange(): + shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: modules.sd_models.reload_model_weights()), call=False) + shared.opts.onchange("sd_vae", wrap_queued_call(lambda: modules.sd_vae.reload_vae_weights()), call=False) + shared.opts.onchange("sd_vae_as_default", wrap_queued_call(lambda: modules.sd_vae.reload_vae_weights()), call=False) + shared.opts.onchange("temp_dir", ui_tempdir.on_tmpdir_changed) + shared.opts.onchange("gradio_theme", shared.reload_gradio_theme) + startup_timer.record("opts onchange") + + def initialize(): fix_asyncio_event_loop_policy() validate_tls_options() @@ -232,13 +241,6 @@ def initialize(): # load model in parallel to other startup stuff Thread(target=lambda: shared.sd_model).start() - shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: modules.sd_models.reload_model_weights()), call=False) - shared.opts.onchange("sd_vae", wrap_queued_call(lambda: modules.sd_vae.reload_vae_weights()), call=False) - shared.opts.onchange("sd_vae_as_default", wrap_queued_call(lambda: modules.sd_vae.reload_vae_weights()), call=False) - shared.opts.onchange("temp_dir", ui_tempdir.on_tmpdir_changed) - shared.opts.onchange("gradio_theme", shared.reload_gradio_theme) - startup_timer.record("opts onchange") - shared.reload_hypernetworks() startup_timer.record("reload hypernets")