aboutsummaryrefslogtreecommitdiff
path: root/webui.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2022-10-02 21:33:32 +0300
committerGitHub <noreply@github.com>2022-10-02 21:33:32 +0300
commitad0503c1b59de0654e3b34c72e81a3c410ba7788 (patch)
tree39c3221e99ca90b7238057bc555c5b4d63fcf960 /webui.py
parent852fd90c0dcda9cb5fbbfdf0c7308ce58034935c (diff)
parent688c4a914a6cb152b5f5e4088bace709ed3dcc35 (diff)
Merge pull request #1454 from AUTOMATIC1111/1404-script-reload-without-restart
Gradio+custom script+js+css reload without model reloading
Diffstat (limited to 'webui.py')
-rw-r--r--webui.py41
1 files changed, 32 insertions, 9 deletions
diff --git a/webui.py b/webui.py
index dc72ceb8..63495697 100644
--- a/webui.py
+++ b/webui.py
@@ -1,4 +1,9 @@
import os
+import threading
+import time
+import importlib
+from modules import devices
+from modules.paths import script_path
import signal
import threading
@@ -82,16 +87,34 @@ def webui():
signal.signal(signal.SIGINT, sigint_handler)
- demo = modules.ui.create_ui(wrap_gradio_gpu_call=wrap_gradio_gpu_call)
+ while 1:
+
+ demo = modules.ui.create_ui(wrap_gradio_gpu_call=wrap_gradio_gpu_call)
+
+ demo.launch(
+ share=cmd_opts.share,
+ server_name="0.0.0.0" if cmd_opts.listen else None,
+ server_port=cmd_opts.port,
+ debug=cmd_opts.gradio_debug,
+ auth=[tuple(cred.split(':')) for cred in cmd_opts.gradio_auth.strip('"').split(',')] if cmd_opts.gradio_auth else None,
+ inbrowser=cmd_opts.autolaunch,
+ prevent_thread_lock=True
+ )
+
+ while 1:
+ time.sleep(0.5)
+ if getattr(demo,'do_restart',False):
+ time.sleep(0.5)
+ demo.close()
+ time.sleep(0.5)
+ break
+
+ print('Reloading Custom Scripts')
+ modules.scripts.reload_scripts(os.path.join(script_path, "scripts"))
+ print('Reloading modules: modules.ui')
+ importlib.reload(modules.ui)
+ print('Restarting Gradio')
- demo.launch(
- share=cmd_opts.share,
- server_name="0.0.0.0" if cmd_opts.listen else None,
- server_port=cmd_opts.port,
- debug=cmd_opts.gradio_debug,
- auth=[tuple(cred.split(':')) for cred in cmd_opts.gradio_auth.strip('"').split(',')] if cmd_opts.gradio_auth else None,
- inbrowser=cmd_opts.autolaunch,
- )
if __name__ == "__main__":