Skip to content

Commit 57d2f2a

Browse files
Alexdnkmashb1t
andauthored
feat: make ui settings more compact (#2590)
* Slightly more compact ui settings Changed Radio to Dropdown. * feat: change preset from option to select, add accordion for resolution * feat: change title of aspect ratios accordion on load and update * refactor: reorder image number slider, code cleanup * fix: add missing scroll down for metadata tab * fix: adjust indent --------- Co-authored-by: Manuel Schmid <[email protected]> Co-authored-by: Manuel Schmid <[email protected]>
1 parent 67289dd commit 57d2f2a

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

css/style.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ progress::after {
107107
overflow: auto !important;
108108
}
109109

110-
.aspect_ratios label {
110+
.performance_selection label {
111111
width: 140px !important;
112112
}
113113

114+
.aspect_ratios label {
115+
flex: calc(50% - 5px) !important;
116+
}
117+
114118
.aspect_ratios label span {
115119
white-space: nowrap !important;
116120
}

webui.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def trigger_show_image_properties(image):
231231
desc_input_image.upload(trigger_show_image_properties, inputs=desc_input_image,
232232
outputs=desc_image_size, show_progress=False, queue=False)
233233

234-
with gr.TabItem(label='Metadata') as load_tab:
234+
with gr.TabItem(label='Metadata') as metadata_tab:
235235
with gr.Column():
236236
metadata_input_image = grh.Image(label='For images created by Fooocus', source='upload', type='filepath')
237237
metadata_json = gr.JSON(label='Metadata')
@@ -264,25 +264,40 @@ def trigger_metadata_preview(filepath):
264264
inpaint_tab.select(lambda: 'inpaint', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
265265
ip_tab.select(lambda: 'ip', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
266266
desc_tab.select(lambda: 'desc', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
267+
metadata_tab.select(lambda: 'metadata', outputs=current_tab, queue=False, _js=down_js, show_progress=False)
267268

268269
with gr.Column(scale=1, visible=modules.config.default_advanced_checkbox) as advanced_column:
269270
with gr.Tab(label='Setting'):
270271
if not args_manager.args.disable_preset_selection:
271-
preset_selection = gr.Radio(label='Preset',
272-
choices=modules.config.available_presets,
273-
value=args_manager.args.preset if args_manager.args.preset else "initial",
274-
interactive=True)
272+
preset_selection = gr.Dropdown(label='Preset',
273+
choices=modules.config.available_presets,
274+
value=args_manager.args.preset if args_manager.args.preset else "initial",
275+
interactive=True)
275276
performance_selection = gr.Radio(label='Performance',
276277
choices=flags.Performance.list(),
277-
value=modules.config.default_performance)
278-
aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=modules.config.available_aspect_ratios_labels,
279-
value=modules.config.default_aspect_ratio, info='width × height',
280-
elem_classes='aspect_ratios')
278+
value=modules.config.default_performance,
279+
elem_classes=['performance_selection'])
280+
with gr.Accordion(label='Aspect Ratios', open=False) as aspect_ratios_accordion:
281+
aspect_ratios_selection = gr.Radio(label='Aspect Ratios', show_label=False,
282+
choices=modules.config.available_aspect_ratios_labels,
283+
value=modules.config.default_aspect_ratio,
284+
info='width × height',
285+
elem_classes='aspect_ratios')
286+
287+
def change_aspect_ratio(text):
288+
import re
289+
regex = re.compile('<.*?>')
290+
cleaned_text = re.sub(regex, '', text)
291+
return gr.update(label='Aspect Ratios ' + cleaned_text)
292+
293+
aspect_ratios_selection.change(change_aspect_ratio, inputs=aspect_ratios_selection, outputs=aspect_ratios_accordion, queue=False, show_progress=False)
294+
shared.gradio_root.load(change_aspect_ratio, inputs=aspect_ratios_selection, outputs=aspect_ratios_accordion, queue=False, show_progress=False)
295+
281296
image_number = gr.Slider(label='Image Number', minimum=1, maximum=modules.config.default_max_image_number, step=1, value=modules.config.default_image_number)
282297

283298
output_format = gr.Radio(label='Output Format',
284-
choices=flags.OutputFormat.list(),
285-
value=modules.config.default_output_format)
299+
choices=flags.OutputFormat.list(),
300+
value=modules.config.default_output_format)
286301

287302
negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.",
288303
info='Describing what you do not want to see.', lines=2,
@@ -603,7 +618,7 @@ def preset_selection_change(preset, is_generating):
603618
return modules.meta_parser.load_parameter_button_click(json.dumps(preset_prepared), is_generating)
604619

605620
preset_selection.change(preset_selection_change, inputs=[preset_selection, state_is_generating], outputs=load_data_outputs, queue=False, show_progress=True) \
606-
.then(fn=style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False) \
621+
.then(fn=style_sorter.sort_styles, inputs=style_selections, outputs=style_selections, queue=False, show_progress=False)
607622

608623
performance_selection.change(lambda x: [gr.update(interactive=not flags.Performance.has_restricted_features(x))] * 11 +
609624
[gr.update(visible=not flags.Performance.has_restricted_features(x))] * 1 +

0 commit comments

Comments
 (0)