aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-02-19 10:53:18 +0300
committerGitHub <noreply@github.com>2023-02-19 10:53:18 +0300
commitb20f28eea9a2f71bb001064f51f1982382bdf568 (patch)
treedc2b8de6c5f683616e922a08702ecb604c69797a /modules
parent9c4eaac61feee2279c84a72deaec7d4413e1b4d3 (diff)
parent742d86eed4d07eef7db65b3d943f85bdbafc26e4 (diff)
Merge pull request #7601 from Gerschel/aspect_ratio_sliders
Aspect ratio sliders
Diffstat (limited to 'modules')
-rw-r--r--modules/shared.py21
-rw-r--r--modules/ui.py12
2 files changed, 31 insertions, 2 deletions
diff --git a/modules/shared.py b/modules/shared.py
index e324a48a..2983ee44 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -139,6 +139,24 @@ ui_reorder_categories = [
"scripts",
]
+aspect_ratio_defaults = [
+ "🔓",
+ "1:1",
+ "3:2",
+ "4:3",
+ "5:4",
+ "16:9",
+ "9:16",
+ "1.85:1",
+ "2.35:1",
+ "2.39:1",
+ "2.40:1",
+ "21:9",
+ "1.375:1",
+ "1.66:1",
+ "1.75:1"
+]
+
cmd_opts.disable_extension_access = (cmd_opts.share or cmd_opts.listen or cmd_opts.server_name) and not cmd_opts.enable_insecure_extension_access
devices.device, devices.device_interrogate, devices.device_gfpgan, devices.device_esrgan, devices.device_codeformer = \
@@ -459,6 +477,9 @@ options_templates.update(options_section(('ui', "User interface"), {
"keyedit_precision_extra": OptionInfo(0.05, "Ctrl+up/down precision when editing <extra networks:0.9>", gr.Slider, {"minimum": 0.01, "maximum": 0.2, "step": 0.001}),
"quicksettings": OptionInfo("sd_model_checkpoint", "Quicksettings list"),
"ui_reorder": OptionInfo(", ".join(ui_reorder_categories), "txt2img/img2img UI item order"),
+ "aspect_ratios_rounding": OptionInfo(True, "Round aspect ratios for more flexibility?", gr.Checkbox),
+ "aspect_ratios_rounding_method": OptionInfo("Ceiling", "Aspect ratios rounding method", gr.Radio,{"choices": ["Round", "Ceiling", "Floor"]}),
+ "aspect_ratios": OptionInfo(", ".join(aspect_ratio_defaults), "txt2img/img2img aspect ratios"),
"ui_extra_networks_tab_reorder": OptionInfo("", "Extra networks tab order"),
"localization": OptionInfo("None", "Localization (requires restart)", gr.Dropdown, lambda: {"choices": ["None"] + list(localization.localizations.keys())}, refresh=lambda: localization.list_localizations(cmd_opts.localizations_dir)),
}))
diff --git a/modules/ui.py b/modules/ui.py
index 2fdbda42..2fc1fee5 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -424,6 +424,10 @@ def ordered_ui_categories():
yield category
+def aspect_ratio_list():
+ return [ratio.strip() for ratio in shared.opts.aspect_ratios.split(",")]
+
+
def get_value_for_setting(key):
value = getattr(opts, key)
@@ -479,7 +483,9 @@ def create_ui():
width = gr.Slider(minimum=64, maximum=2048, step=8, label="Width", value=512, elem_id="txt2img_width")
height = gr.Slider(minimum=64, maximum=2048, step=8, label="Height", value=512, elem_id="txt2img_height")
- res_switch_btn = ToolButton(value=switch_values_symbol, elem_id="txt2img_res_switch_btn")
+ with gr.Column(elem_id="txt2img_size_toolbox", scale=0):
+ aspect_ratio_dropdown = gr.Dropdown(value="🔓", choices=aspect_ratio_list(), interactive=True, type="value", elem_id="txt2img_ratio", show_label=False, label="Aspect Ratio")
+ res_switch_btn = ToolButton(value=switch_values_symbol, elem_id="txt2img_res_switch_btn")
if opts.dimensions_and_batch_together:
with gr.Column(elem_id="txt2img_column_batch"):
batch_count = gr.Slider(minimum=1, step=1, label='Batch count', value=1, elem_id="txt2img_batch_count")
@@ -757,7 +763,9 @@ def create_ui():
width = gr.Slider(minimum=64, maximum=2048, step=8, label="Width", value=512, elem_id="img2img_width")
height = gr.Slider(minimum=64, maximum=2048, step=8, label="Height", value=512, elem_id="img2img_height")
- res_switch_btn = ToolButton(value=switch_values_symbol, elem_id="img2img_res_switch_btn")
+ with gr.Column(elem_id="img2img_size_toolbox", scale=0):
+ aspect_ratio_dropdown = gr.Dropdown(value="🔓", choices=aspect_ratio_list(), interactive=True, type="value", elem_id="img2img_ratio", show_label=False, label="Aspect Ratio")
+ res_switch_btn = ToolButton(value=switch_values_symbol, elem_id="img2img_res_switch_btn")
if opts.dimensions_and_batch_together:
with gr.Column(elem_id="img2img_column_batch"):
batch_count = gr.Slider(minimum=1, step=1, label='Batch count', value=1, elem_id="img2img_batch_count")