-
Notifications
You must be signed in to change notification settings - Fork 69
/
webui.py
56 lines (41 loc) · 1.29 KB
/
webui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import time
from fastapi import FastAPI
if "--tensorrt" in os.environ.get("COMMANDLINE_ARGS", ""):
import tensorrt as trt
from lib.tensorrt.utilities import TRT_LOGGER
print(f"TensorRT version: {trt.__version__}")
trt.init_libnvinfer_plugins(TRT_LOGGER, "")
from api.events.common import (PostAppLaunchEvent, PostUICreateEvent,
PreAppLaunchEvent, PreUICreateEvent)
from modules import config, javascripts, model_manager, plugin_loader, ui
from modules.diffusion import embeddings, networks
def pre_load():
config.init()
plugin_loader.load_plugins()
PreAppLaunchEvent.call_event()
networks.init()
embeddings.init()
model_manager.init()
def post_load(app: FastAPI):
javascripts.apply_javascript_api(app)
PostAppLaunchEvent.call_event(app)
def wait_on_server():
while 1:
time.sleep(0.5)
def webui():
pre_load()
PreUICreateEvent.call_event()
app = ui.create_ui()
PostUICreateEvent.call_event(app)
app.queue(64)
app, local_url, share_url = app.launch(
server_name=config.get("host"),
server_port=config.get("port"),
share=config.get("share"),
prevent_thread_lock=True,
)
post_load(app)
wait_on_server()
if __name__ == "__main__":
webui()