aboutsummaryrefslogtreecommitdiff
path: root/webui.py
diff options
context:
space:
mode:
Diffstat (limited to 'webui.py')
-rw-r--r--webui.py47
1 files changed, 19 insertions, 28 deletions
diff --git a/webui.py b/webui.py
index 7a4bb2a2..ad2eb236 100644
--- a/webui.py
+++ b/webui.py
@@ -9,7 +9,7 @@ from fastapi.middleware.gzip import GZipMiddleware
from modules.paths import script_path
-from modules import devices, sd_samplers, upscaler
+from modules import devices, sd_samplers, upscaler, extensions
import modules.codeformer_model as codeformer
import modules.extras
import modules.face_restoration
@@ -46,26 +46,13 @@ def wrap_queued_call(func):
def wrap_gradio_gpu_call(func, extra_outputs=None):
def f(*args, **kwargs):
- devices.torch_gc()
-
- shared.state.sampling_step = 0
- shared.state.job_count = -1
- shared.state.job_no = 0
- shared.state.job_timestamp = shared.state.get_job_timestamp()
- shared.state.current_latent = None
- shared.state.current_image = None
- shared.state.current_image_sampling_step = 0
- shared.state.skipped = False
- shared.state.interrupted = False
- shared.state.textinfo = None
+
+ shared.state.begin()
with queue_lock:
res = func(*args, **kwargs)
- shared.state.job = ""
- shared.state.job_count = 0
-
- devices.torch_gc()
+ shared.state.end()
return res
@@ -73,6 +60,11 @@ def wrap_gradio_gpu_call(func, extra_outputs=None):
def initialize():
+ extensions.list_extensions()
+ #for ext in extensions.extensions:
+ # print(ext.name, ext.path, ext.enabled, ext.remote)
+ #exit()
+
if cmd_opts.ui_debug_mode:
shared.sd_upscalers = upscaler.UpscalerLanczos().scalers
modules.scripts.load_scripts()
@@ -105,15 +97,18 @@ def create_api(app):
api = Api(app, queue_lock)
return api
+
def wait_on_server(demo=None):
while 1:
time.sleep(0.5)
- if demo and getattr(demo, 'do_restart', False):
+ if shared.state.need_restart:
+ shared.state.need_restart = False
time.sleep(0.5)
demo.close()
time.sleep(0.5)
break
+
def api_only():
initialize()
@@ -145,16 +140,16 @@ def webui():
app.add_middleware(GZipMiddleware, minimum_size=1000)
- if (launch_api):
- print('launching API')
- api = create_api(app)
- api.launch(server_name="0.0.0.0" if cmd_opts.listen else "127.0.0.1", port=cmd_opts.port if cmd_opts.port else 7861)
+ if launch_api:
+ create_api(app)
wait_on_server(demo)
sd_samplers.set_samplers()
- print('Reloading Custom Scripts')
+ print('Reloading extensions')
+ extensions.list_extensions()
+ print('Reloading custom scripts')
modules.scripts.reload_scripts()
print('Reloading modules: modules.ui')
importlib.reload(modules.ui)
@@ -163,12 +158,8 @@ def webui():
print('Restarting Gradio')
-def webui_or_api():
+if __name__ == "__main__":
if cmd_opts.nowebui:
api_only()
else:
webui()
-
-task = []
-if __name__ == "__main__":
- webui_or_api() \ No newline at end of file