Upload 2 files
Browse files- .gitattributes +1 -0
- direct/forge/directui.py +145 -0
- direct/forge/repositories.tar +3 -0
.gitattributes
CHANGED
@@ -41,3 +41,4 @@ direct/install_comfyui.tar filter=lfs diff=lfs merge=lfs -text
|
|
41 |
direct/install_comfyui_face.tar filter=lfs diff=lfs merge=lfs -text
|
42 |
direct/install_comfyui_pack.tar filter=lfs diff=lfs merge=lfs -text
|
43 |
direct/install_comfyui_pack_20240225.tar filter=lfs diff=lfs merge=lfs -text
|
|
|
|
41 |
direct/install_comfyui_face.tar filter=lfs diff=lfs merge=lfs -text
|
42 |
direct/install_comfyui_pack.tar filter=lfs diff=lfs merge=lfs -text
|
43 |
direct/install_comfyui_pack_20240225.tar filter=lfs diff=lfs merge=lfs -text
|
44 |
+
direct/forge/repositories.tar filter=lfs diff=lfs merge=lfs -text
|
direct/forge/directui.py
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
|
3 |
+
import os
|
4 |
+
import time
|
5 |
+
|
6 |
+
from modules import timer
|
7 |
+
from modules import initialize_util
|
8 |
+
from modules import initialize
|
9 |
+
|
10 |
+
startup_timer = timer.startup_timer
|
11 |
+
startup_timer.record("launcher")
|
12 |
+
|
13 |
+
initialize.imports()
|
14 |
+
|
15 |
+
initialize.check_versions()
|
16 |
+
|
17 |
+
|
18 |
+
def create_api(app):
|
19 |
+
from modules.api.api import Api
|
20 |
+
from modules.call_queue import queue_lock
|
21 |
+
|
22 |
+
api = Api(app, queue_lock)
|
23 |
+
return api
|
24 |
+
|
25 |
+
|
26 |
+
def api_only():
|
27 |
+
from fastapi import FastAPI
|
28 |
+
from modules.shared_cmd_options import cmd_opts
|
29 |
+
|
30 |
+
initialize.initialize()
|
31 |
+
|
32 |
+
app = FastAPI()
|
33 |
+
initialize_util.setup_middleware(app)
|
34 |
+
api = create_api(app)
|
35 |
+
|
36 |
+
from modules import script_callbacks
|
37 |
+
|
38 |
+
script_callbacks.before_ui_callback()
|
39 |
+
script_callbacks.app_started_callback(None, app)
|
40 |
+
|
41 |
+
print(f"Startup time: {startup_timer.summary()}.")
|
42 |
+
api.launch(
|
43 |
+
server_name="0.0.0.0" if cmd_opts.listen else "127.0.0.1",
|
44 |
+
port=cmd_opts.port if cmd_opts.port else 7861,
|
45 |
+
root_path=f"/{cmd_opts.subpath}" if cmd_opts.subpath else "",
|
46 |
+
)
|
47 |
+
|
48 |
+
|
49 |
+
def webui():
|
50 |
+
from modules.shared_cmd_options import cmd_opts
|
51 |
+
|
52 |
+
launch_api = cmd_opts.api
|
53 |
+
initialize.initialize()
|
54 |
+
|
55 |
+
from modules import (
|
56 |
+
shared,
|
57 |
+
ui_tempdir,
|
58 |
+
script_callbacks,
|
59 |
+
ui,
|
60 |
+
progress,
|
61 |
+
ui_extra_networks,
|
62 |
+
)
|
63 |
+
|
64 |
+
while 1:
|
65 |
+
if shared.opts.clean_temp_dir_at_start:
|
66 |
+
ui_tempdir.cleanup_tmpdr()
|
67 |
+
startup_timer.record("cleanup temp dir")
|
68 |
+
|
69 |
+
script_callbacks.before_ui_callback()
|
70 |
+
startup_timer.record("scripts before_ui_callback")
|
71 |
+
|
72 |
+
shared.demo = ui.create_ui()
|
73 |
+
startup_timer.record("create ui")
|
74 |
+
|
75 |
+
app, local_url, share_url = shared.demo.launch(
|
76 |
+
height=3000, prevent_thread_lock=True
|
77 |
+
)
|
78 |
+
|
79 |
+
startup_timer.record("gradio launch")
|
80 |
+
|
81 |
+
# gradio uses a very open CORS policy via app.user_middleware, which makes it possible for
|
82 |
+
# an attacker to trick the user into opening a malicious HTML page, which makes a request to the
|
83 |
+
# running web ui and do whatever the attacker wants, including installing an extension and
|
84 |
+
# running its code. We disable this here. Suggested by RyotaK.
|
85 |
+
app.user_middleware = [
|
86 |
+
x for x in app.user_middleware if x.cls.__name__ != "CORSMiddleware"
|
87 |
+
]
|
88 |
+
|
89 |
+
initialize_util.setup_middleware(app)
|
90 |
+
|
91 |
+
progress.setup_progress_api(app)
|
92 |
+
ui.setup_ui_api(app)
|
93 |
+
|
94 |
+
if launch_api:
|
95 |
+
create_api(app)
|
96 |
+
|
97 |
+
ui_extra_networks.add_pages_to_demo(app)
|
98 |
+
|
99 |
+
startup_timer.record("add APIs")
|
100 |
+
|
101 |
+
with startup_timer.subcategory("app_started_callback"):
|
102 |
+
script_callbacks.app_started_callback(shared.demo, app)
|
103 |
+
|
104 |
+
timer.startup_record = startup_timer.dump()
|
105 |
+
print(f"Startup time: {startup_timer.summary()}.")
|
106 |
+
|
107 |
+
try:
|
108 |
+
while True:
|
109 |
+
server_command = shared.state.wait_for_server_command(timeout=5)
|
110 |
+
if server_command:
|
111 |
+
if server_command in ("stop", "restart"):
|
112 |
+
break
|
113 |
+
else:
|
114 |
+
print(f"Unknown server command: {server_command}")
|
115 |
+
except KeyboardInterrupt:
|
116 |
+
print("Caught KeyboardInterrupt, stopping...")
|
117 |
+
server_command = "stop"
|
118 |
+
|
119 |
+
if server_command == "stop":
|
120 |
+
print("Stopping server...")
|
121 |
+
# If we catch a keyboard interrupt, we want to stop the server and exit.
|
122 |
+
shared.demo.close()
|
123 |
+
break
|
124 |
+
|
125 |
+
# disable auto launch webui in browser for subsequent UI Reload
|
126 |
+
os.environ.setdefault("SD_WEBUI_RESTARTING", "1")
|
127 |
+
|
128 |
+
print("Restarting UI...")
|
129 |
+
shared.demo.close()
|
130 |
+
time.sleep(0.5)
|
131 |
+
startup_timer.reset()
|
132 |
+
script_callbacks.app_reload_callback()
|
133 |
+
startup_timer.record("app reload callback")
|
134 |
+
script_callbacks.script_unloaded_callback()
|
135 |
+
startup_timer.record("scripts unloaded callback")
|
136 |
+
initialize.initialize_rest(reload_script_modules=True)
|
137 |
+
|
138 |
+
|
139 |
+
if __name__ == "__main__":
|
140 |
+
from modules.shared_cmd_options import cmd_opts
|
141 |
+
|
142 |
+
if cmd_opts.nowebui:
|
143 |
+
api_only()
|
144 |
+
else:
|
145 |
+
webui()
|
direct/forge/repositories.tar
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6f5b897a511af311cda44a5be3da40cf33196366734fc9d6ea763ab8c7a638d1
|
3 |
+
size 222383104
|