From a975a6a03dd71489ecc7e07cf3444b7beda765f6 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Tue, 18 Apr 2023 08:06:16 -0400 Subject: [PATCH] disable gradio queues on demand --- .gitignore | 2 +- TODO.md | 5 +++++ modules/cmd_args.py | 1 + modules/shared.py | 4 ++-- modules/ui.py | 2 +- webui.py | 4 +++- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 810d1f84d..b199e2c98 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ __pycache__ /config.json /ui-config.json /setup.log -/style.csv +/styles.csv /user.css /javascript/themes.json venv diff --git a/TODO.md b/TODO.md index 323ace9ad..ddf91cde2 100644 --- a/TODO.md +++ b/TODO.md @@ -82,3 +82,8 @@ Tech that can be integrated as part of the core workflow... ## Random - Bunch of stuff: + +### Update + +- force unload `xformers` when not used, improves compatibility with AMD/M1 +- add `styles.csv` to UI settings to allow customizing path diff --git a/modules/cmd_args.py b/modules/cmd_args.py index bdc3dd5b6..c85b8e3d4 100644 --- a/modules/cmd_args.py +++ b/modules/cmd_args.py @@ -46,6 +46,7 @@ parser.add_argument("--server-name", type=str, help="Sets hostname of server", d parser.add_argument("--no-hashing", action='store_true', help="Disable sha256 hashing of checkpoints", default=False) parser.add_argument("--no-download-sd-model", action='store_true', help="Disable download of default model even if no model is found", default=False) parser.add_argument("--profile", action='store_true', help="Run profiler, default: %(default)s") +parser.add_argument("--disable-queue", action='store_true', help="Disable Gradio queues and force use of HTTP instead of WebSockets, default: %(default)s") def compatibility_args(opts, args): diff --git a/modules/shared.py b/modules/shared.py index c8353b6d9..1c5003032 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -170,8 +170,6 @@ class State: state = State() state.server_start = time.time() -prompt_styles = modules.styles.StyleDatabase('styles.csv') - interrogator = modules.interrogate.InterrogateModels("interrogate") face_restorers = [] @@ -278,6 +276,7 @@ options_templates.update(options_section(('system-paths', "System Paths"), { "clip_models_path": OptionInfo(os.path.join(paths.models_path, 'CLIP'), "Path to directory with CLIP model file(s)"), "lora_dir": OptionInfo(os.path.join(paths.models_path, 'Lora'), "Path to directory with Lora network(s)"), "lyco_dir": OptionInfo(os.path.join(paths.models_path, 'LyCORIS'), "Path to directory with LyCORIS network(s)"), + "styles_dir": OptionInfo('styles.csv', "Path to user-defined styles file"), # "gfpgan_model": OptionInfo("", "GFPGAN model file name"), })) @@ -607,6 +606,7 @@ if os.path.exists(config_filename): opts.load(config_filename) cmd_opts = cmd_args.compatibility_args(opts, cmd_opts) +prompt_styles = modules.styles.StyleDatabase(opts.styles_dir) settings_components = None """assinged from ui.py, a mapping on setting names to gradio components repsponsible for those settings""" diff --git a/modules/ui.py b/modules/ui.py index 6d5b6a5f3..cba8d63de 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -89,7 +89,7 @@ def add_style(name: str, prompt: str, negative_prompt: str): shared.prompt_styles.styles[style.name] = style # Save all loaded prompt styles: this allows us to update the storage format in the future more easily, because we # reserialize all styles every time we save them - shared.prompt_styles.save_styles('styles.csv') + shared.prompt_styles.save_styles(shared.opts.styles_dir) return [gr.Dropdown.update(visible=True, choices=list(shared.prompt_styles.styles)) for _ in range(2)] diff --git a/webui.py b/webui.py index 7204c7f73..9576c822e 100644 --- a/webui.py +++ b/webui.py @@ -160,7 +160,9 @@ def start_ui(): startup_timer.record("scripts before_ui_callback") shared.demo = modules.ui.create_ui() startup_timer.record("ui") - shared.demo.queue(16) + if cmd_opts.disable_queue: + print('Server queues disabled') + shared.demo.queue(16) gradio_auth_creds = [] if cmd_opts.gradio_auth: