From 797f805b7f211b33550c3e9674f496f1712ef9fd Mon Sep 17 00:00:00 2001 From: Manuel Schmid <9307310+mashb1t@users.noreply.github.com> Date: Fri, 17 May 2024 18:25:08 +0200 Subject: [PATCH] feat: automatically describe image on uov image upload (#1938) * feat: automatically describe image on uov image upload if prompt is empty * feat: add argument to disable automatic uov image description * feat: rename argument, disable by default this prevents computers with low hardware specifications from being unnecessary blocked --- args_manager.py | 3 +++ webui.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/args_manager.py b/args_manager.py index 6a3ae9dc3e..e023da2769 100644 --- a/args_manager.py +++ b/args_manager.py @@ -31,6 +31,9 @@ args_parser.parser.add_argument("--disable-preset-download", action='store_true', help="Disables downloading models for presets", default=False) +args_parser.parser.add_argument("--enable-describe-uov-image", action='store_true', + help="Disables automatic description of uov images when prompt is empty", default=False) + args_parser.parser.add_argument("--always-download-new-model", action='store_true', help="Always download newer models ", default=False) diff --git a/webui.py b/webui.py index 85b2c0df3b..f99ab15917 100644 --- a/webui.py +++ b/webui.py @@ -717,6 +717,15 @@ def trigger_describe(mode, img): desc_btn.click(trigger_describe, inputs=[desc_method, desc_input_image], outputs=[prompt, style_selections], show_progress=True, queue=True) + if args_manager.args.enable_describe_uov_image: + def trigger_uov_describe(mode, img, prompt): + # keep prompt if not empty + if prompt == '': + return trigger_describe(mode, img) + return gr.update(), gr.update() + + uov_input_image.upload(trigger_uov_describe, inputs=[desc_method, uov_input_image, prompt], + outputs=[prompt, style_selections], show_progress=True, queue=True) def dump_default_english_config(): from modules.localization import dump_english_config