Refactor configure opts_onchange out

This commit is contained in:
Aarni Koskela 2023-05-19 16:00:53 +03:00
parent 8200e0c27b
commit 8a178e6717

View File

@ -190,6 +190,15 @@ def configure_sigint_handler():
signal.signal(signal.SIGINT, 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(): def initialize():
fix_asyncio_event_loop_policy() fix_asyncio_event_loop_policy()
validate_tls_options() validate_tls_options()
@ -232,13 +241,6 @@ def initialize():
# load model in parallel to other startup stuff # load model in parallel to other startup stuff
Thread(target=lambda: shared.sd_model).start() 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() shared.reload_hypernetworks()
startup_timer.record("reload hypernets") startup_timer.record("reload hypernets")