From d4d5e4c3a72c078343d47239b39a8266dab057ba Mon Sep 17 00:00:00 2001 From: Alexdnk <83111151+Alexdnk@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:52:29 +0700 Subject: [PATCH 1/6] Slightly more compact ui settings Changed Radio to Dropdown. --- webui.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/webui.py b/webui.py index 98780bff..21545057 100644 --- a/webui.py +++ b/webui.py @@ -257,22 +257,25 @@ with shared.gradio_root: with gr.Column(scale=1, visible=modules.config.default_advanced_checkbox) as advanced_column: with gr.Tab(label='Setting'): - if not args_manager.args.disable_preset_selection: - preset_selection = gr.Radio(label='Preset', - choices=modules.config.available_presets, - value=args_manager.args.preset if args_manager.args.preset else "initial", - interactive=True) - performance_selection = gr.Radio(label='Performance', - choices=flags.Performance.list(), - value=modules.config.default_performance) - aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios, - value=modules.config.default_aspect_ratio, info='width × height', - elem_classes='aspect_ratios') - image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number) + with gr.Row(): + if not args_manager.args.disable_preset_selection: + preset_selection = gr.Dropdown(label='Preset', + choices=modules.config.available_presets, + value=args_manager.args.preset if args_manager.args.preset else "initial", + interactive=True, scale=3) + performance_selection = gr.Dropdown(label='Performance', + choices=flags.Performance.list(), + value=modules.config.default_performance, scale=1) + with gr.Accordion('Resolution'): + aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios, + value=modules.config.default_aspect_ratio, info='width × height', + elem_classes='aspect_ratios') - output_format = gr.Radio(label='Output Format', - choices=flags.OutputFormat.list(), - value=modules.config.default_output_format) + with gr.Row(): + output_format = gr.Dropdown(label='Output Format', + choices=flags.OutputFormat.list(), + value=modules.config.default_output_format, scale=1) + image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number, scale=3) negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.", info='Describing what you do not want to see.', lines=2, From a0114de9e9aae92f1cde31bc21752c60e45fd113 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Thu, 23 May 2024 01:21:08 +0200 Subject: [PATCH 2/6] feat: change preset from option to select, add accordion for resolution --- css/style.css | 6 +++++- webui.py | 29 ++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/css/style.css b/css/style.css index c702a725..8bcb9ed3 100644 --- a/css/style.css +++ b/css/style.css @@ -101,10 +101,14 @@ progress::after { overflow: auto !important; } -.aspect_ratios label { +.performance_selection label { width: 140px !important; } +.aspect_ratios label { + flex: calc(50% - 5px) !important; +} + .aspect_ratios label span { white-space: nowrap !important; } diff --git a/webui.py b/webui.py index 21545057..873c7e75 100644 --- a/webui.py +++ b/webui.py @@ -257,25 +257,24 @@ with shared.gradio_root: with gr.Column(scale=1, visible=modules.config.default_advanced_checkbox) as advanced_column: with gr.Tab(label='Setting'): - with gr.Row(): - if not args_manager.args.disable_preset_selection: - preset_selection = gr.Dropdown(label='Preset', - choices=modules.config.available_presets, - value=args_manager.args.preset if args_manager.args.preset else "initial", - interactive=True, scale=3) - performance_selection = gr.Dropdown(label='Performance', - choices=flags.Performance.list(), - value=modules.config.default_performance, scale=1) - with gr.Accordion('Resolution'): + if not args_manager.args.disable_preset_selection: + preset_selection = gr.Dropdown(label='Preset', + choices=modules.config.available_presets, + value=args_manager.args.preset if args_manager.args.preset else "initial", + interactive=True) + performance_selection = gr.Radio(label='Performance', + choices=flags.Performance.list(), + value=modules.config.default_performance, + elem_classes=['performance_selection']) + with gr.Accordion('Resolution', open=False): aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios, value=modules.config.default_aspect_ratio, info='width × height', elem_classes='aspect_ratios') - with gr.Row(): - output_format = gr.Dropdown(label='Output Format', - choices=flags.OutputFormat.list(), - value=modules.config.default_output_format, scale=1) - image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number, scale=3) + output_format = gr.Radio(label='Output Format', + choices=flags.OutputFormat.list(), + value=modules.config.default_output_format) + image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number, scale=3) negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.", info='Describing what you do not want to see.', lines=2, From 011f65ba78ee5eadea5bad300bdc8a447ecf41fb Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 26 May 2024 16:09:23 +0200 Subject: [PATCH 3/6] feat: change title of aspect ratios accordion on load and update --- webui.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/webui.py b/webui.py index 873c7e75..43aa3b74 100644 --- a/webui.py +++ b/webui.py @@ -266,11 +266,25 @@ with shared.gradio_root: choices=flags.Performance.list(), value=modules.config.default_performance, elem_classes=['performance_selection']) - with gr.Accordion('Resolution', open=False): - aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios, - value=modules.config.default_aspect_ratio, info='width × height', + with gr.Accordion(label='Aspect Ratios', open=False) as aspect_ratios_accordion: + aspect_ratios_selection = gr.Radio(label='Aspect Ratios', show_label=False, + choices=modules.config.available_aspect_ratios, + value=modules.config.default_aspect_ratio, + info='width × height', elem_classes='aspect_ratios') + def change_aspect_ratio(text): + import re + regex = re.compile('<.*?>') + cleaned_text = re.sub(regex, '', text) + return gr.update(label='Aspect Ratios ' + cleaned_text) + + aspect_ratios_selection.change(change_aspect_ratio, inputs=aspect_ratios_selection, + outputs=aspect_ratios_accordion, show_progress=False, queue=False) + + shared.gradio_root.load(change_aspect_ratio, inputs=aspect_ratios_selection, + outputs=aspect_ratios_accordion, queue=False, show_progress=False) + output_format = gr.Radio(label='Output Format', choices=flags.OutputFormat.list(), value=modules.config.default_output_format) From be5a152c076298d646a244c210bf5f9a7f0f1734 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 26 May 2024 17:18:03 +0200 Subject: [PATCH 4/6] refactor: reorder image number slider, code cleanup --- webui.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/webui.py b/webui.py index 43aa3b74..2a6eaeca 100644 --- a/webui.py +++ b/webui.py @@ -279,16 +279,14 @@ with shared.gradio_root: cleaned_text = re.sub(regex, '', text) return gr.update(label='Aspect Ratios ' + cleaned_text) - aspect_ratios_selection.change(change_aspect_ratio, inputs=aspect_ratios_selection, - outputs=aspect_ratios_accordion, show_progress=False, queue=False) + aspect_ratios_selection.change(change_aspect_ratio, inputs=aspect_ratios_selection, outputs=aspect_ratios_accordion, queue=False, show_progress=False) + shared.gradio_root.load(change_aspect_ratio, inputs=aspect_ratios_selection, outputs=aspect_ratios_accordion, queue=False, show_progress=False) - shared.gradio_root.load(change_aspect_ratio, inputs=aspect_ratios_selection, - outputs=aspect_ratios_accordion, queue=False, show_progress=False) + image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number) output_format = gr.Radio(label='Output Format', choices=flags.OutputFormat.list(), value=modules.config.default_output_format) - image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number, scale=3) negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.", info='Describing what you do not want to see.', lines=2, @@ -586,7 +584,7 @@ with shared.gradio_root: return modules.meta_parser.load_parameter_button_click(json.dumps(preset_prepared), is_generating) preset_selection.change(preset_selection_change, inputs=[preset_selection, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=True) \ - .then(fn=style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False) \ + .then(fn=style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False) performance_selection.change(lambda x: [gr.update(interactive=not flags.Performance.has_restricted_features(x))] * 11 + [gr.update(visible=not flags.Performance.has_restricted_features(x))] * 1 + From 7b60f1efdd7436ac2999c68a472db4e7a22259db Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 26 May 2024 17:18:50 +0200 Subject: [PATCH 5/6] fix: add missing scroll down for metadata tab --- webui.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webui.py b/webui.py index 2a6eaeca..ec5dd173 100644 --- a/webui.py +++ b/webui.py @@ -221,7 +221,7 @@ with shared.gradio_root: value=flags.desc_type_photo) desc_btn = gr.Button(value='Describe this Image into Prompt') gr.HTML('\U0001F4D4 Document') - with gr.TabItem(label='Metadata') as load_tab: + with gr.TabItem(label='Metadata') as metadata_tab: with gr.Column(): metadata_input_image = grh.Image(label='Drag any image generated by Fooocus here', source='upload', type='filepath') metadata_json = gr.JSON(label='Metadata') @@ -254,6 +254,7 @@ with shared.gradio_root: inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False, _js=down_js, show_progress=False) ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False) desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False) + metadata_tab.select(lambda: 'metadata', outputs=current_tab, queue=False, _js=down_js, show_progress=False) with gr.Column(scale=1, visible=modules.config.default_advanced_checkbox) as advanced_column: with gr.Tab(label='Setting'): From fced8b4c24fbbcb598c79863f63f24114628acd7 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Sun, 26 May 2024 17:25:08 +0200 Subject: [PATCH 6/6] fix: adjust indent --- webui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webui.py b/webui.py index 8234497b..1d5bec92 100644 --- a/webui.py +++ b/webui.py @@ -231,7 +231,7 @@ with shared.gradio_root: desc_input_image.upload(trigger_show_image_properties, inputs=desc_input_image, outputs=desc_image_size, show_progress=False, queue=False) - with gr.TabItem(label='Metadata') as metadata_tab: + with gr.TabItem(label='Metadata') as metadata_tab: with gr.Column(): metadata_input_image = grh.Image(label='For images created by Fooocus', source='upload', type='filepath') metadata_json = gr.JSON(label='Metadata')