diff --git a/modules/path.py b/modules/path.py index a305060a..53147b74 100644 --- a/modules/path.py +++ b/modules/path.py @@ -119,6 +119,11 @@ checkpoint_downloads = get_config_item_or_set_default( }, validator=lambda x: isinstance(x, dict) and all(isinstance(k, str) and isinstance(v, str) for k, v in x.items()) ) +default_aspect_ratio = get_config_item_or_set_default( + key='default_aspect_ratio', + default_value='1152*896', + validator=lambda x: x.replace('*', '×') in modules.sdxl_styles.aspect_ratios +).replace('*', '×') with open(config_path, "w", encoding="utf-8") as json_file: json.dump(config_dict, json_file, indent=4) diff --git a/modules/sdxl_styles.py b/modules/sdxl_styles.py index 8b38e6e6..37d9808b 100644 --- a/modules/sdxl_styles.py +++ b/modules/sdxl_styles.py @@ -966,7 +966,6 @@ SD_XL_BASE_RATIOS = { } aspect_ratios = {} -default_aspect_ratio = None # import math @@ -977,8 +976,6 @@ for k, (w, h) in SD_XL_BASE_RATIOS.items(): # txt += f' {w//gcd}:{h//gcd}' aspect_ratios[txt] = (w, h) - if k == "1.29": - default_aspect_ratio = txt def apply_style(style, positive): diff --git a/webui.py b/webui.py index 51a101c1..374837de 100644 --- a/webui.py +++ b/webui.py @@ -13,7 +13,7 @@ import modules.gradio_hijack as grh import modules.advanced_parameters as advanced_parameters import args_manager -from modules.sdxl_styles import legal_style_names, aspect_ratios, default_aspect_ratio +from modules.sdxl_styles import legal_style_names, aspect_ratios from modules.private_logger import get_current_html_path @@ -176,7 +176,7 @@ with shared.gradio_root: with gr.Tab(label='Setting'): performance_selection = gr.Radio(label='Performance', choices=['Speed', 'Quality'], value='Speed') aspect_ratios_selection = gr.Radio(label='Aspect Ratios', choices=list(aspect_ratios.keys()), - value=default_aspect_ratio, info='width × height') + value=modules.path.default_aspect_ratio, info='width × height') image_number = gr.Slider(label='Image Number', minimum=1, maximum=32, step=1, value=2) 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,