mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-05 03:32:37 +00:00
settings categories split to columns, remade categories
This commit is contained in:
@@ -9,7 +9,6 @@ import random
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
import itertools
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
@@ -23,7 +22,6 @@ from modules.paths import script_path
|
||||
from modules.shared import opts, cmd_opts
|
||||
import modules.shared as shared
|
||||
from modules.sd_samplers import samplers, samplers_for_img2img
|
||||
import modules.realesrgan_model as realesrgan
|
||||
import modules.ldsr_model
|
||||
import modules.scripts
|
||||
import modules.gfpgan_model
|
||||
@@ -815,9 +813,6 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
||||
return comp(label=info.label, value=fun, **(args or {}))
|
||||
|
||||
components = []
|
||||
keys = list(opts.data_labels.keys())
|
||||
settings_cols = 3
|
||||
items_per_col = math.ceil(len(keys) / settings_cols)
|
||||
|
||||
def run_settings(*args):
|
||||
up = []
|
||||
@@ -843,28 +838,33 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
||||
settings_submit = gr.Button(value="Apply settings", variant='primary')
|
||||
result = gr.HTML()
|
||||
|
||||
sortedKeys = sorted([(opts.data_labels[key].section,key) for key in keys],key=lambda x:x[0])
|
||||
groupedKeys = itertools.groupby(sortedKeys,key=lambda x:x[0])
|
||||
settings_cols = 3
|
||||
items_per_col = int(len(opts.data_labels) * 0.9 / settings_cols)
|
||||
|
||||
for (sectionNumber,sectionName),sectionGroup in groupedKeys:
|
||||
with gr.Row(elem_id="settings_header_{}".format(sectionNumber)).style(equal_height=False):
|
||||
gr.HTML(elem_id="settings_header_text_{}".format(sectionNumber), value='<h1 class="gr-button-lg">{}</h1>'.format(sectionName))
|
||||
cols_displayed = 0
|
||||
items_displayed = 0
|
||||
previous_section = None
|
||||
column = None
|
||||
with gr.Row(elem_id="settings").style(equal_height=False):
|
||||
for i, (k, item) in enumerate(opts.data_labels.items()):
|
||||
|
||||
with gr.Row(elem_id="settings_{}".format(sectionNumber)).style(equal_height=False):
|
||||
columnLookup = {}
|
||||
for colNum,element in zip(itertools.cycle(range(settings_cols)),sectionGroup):
|
||||
columnLookup.setdefault(colNum,[]).append(element)
|
||||
if previous_section != item.section:
|
||||
if cols_displayed < settings_cols and (items_displayed >= items_per_col or previous_section is None):
|
||||
if column is not None:
|
||||
column.__exit__()
|
||||
|
||||
for colno,elements in sorted(columnLookup.items()):
|
||||
with gr.Column(variant='panel'):
|
||||
for _,keyElement in elements:
|
||||
components.append(create_setting_component(keyElement))
|
||||
column = gr.Column(variant='panel')
|
||||
column.__enter__()
|
||||
|
||||
settings_submit.click(
|
||||
fn=run_settings,
|
||||
inputs=components,
|
||||
outputs=[result]
|
||||
)
|
||||
items_displayed = 0
|
||||
cols_displayed += 1
|
||||
|
||||
previous_section = item.section
|
||||
|
||||
gr.HTML(elem_id="settings_header_text_{}".format(item.section[0]), value='<h1 class="gr-button-lg">{}</h1>'.format(item.section[1]))
|
||||
|
||||
components.append(create_setting_component(k))
|
||||
items_displayed += 1
|
||||
|
||||
request_notifications = gr.Button(value='Request browser notifications', elem_id="request_notifications")
|
||||
request_notifications.click(
|
||||
@@ -874,6 +874,15 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
|
||||
_js='function(){}'
|
||||
)
|
||||
|
||||
if column is not None:
|
||||
column.__exit__()
|
||||
|
||||
settings_submit.click(
|
||||
fn=run_settings,
|
||||
inputs=components,
|
||||
outputs=[result]
|
||||
)
|
||||
|
||||
interfaces = [
|
||||
(txt2img_interface, "txt2img", "txt2img"),
|
||||
(img2img_interface, "img2img", "img2img"),
|
||||
|
Reference in New Issue
Block a user