aboutsummaryrefslogtreecommitdiff
path: root/modules/ui.py
diff options
context:
space:
mode:
authorGerschel <Gerschel_Payne@hotmail.com>2023-02-06 08:18:04 -0800
committerGerschel <Gerschel_Payne@hotmail.com>2023-02-06 08:18:04 -0800
commit5d483bf307c766aee97caec857d414946fad47db (patch)
tree500535fbebe327de651d9878b98d7024a8578079 /modules/ui.py
parentea9bd9fc7409109adcd61b897abc2c8881161256 (diff)
aspect ratio for dim's; sliders adjust by ratio
Default choices added to settings in user interface section Choices are editable by user User selects from dropdown. When you move one slider, the other adjusts according to the ratio chosen. Vice versa for the other slider. Number fields for changes work as well. For disabling ratio, an unlock pad "🔓" is available as a default. This string can be changed to anything to serve as a disable, as long as there is no colon ":". Ratios are entered in this format, floats or ints with a colon "1:1". The string is split at the colon, parses left and right as floats to perform the math.
Diffstat (limited to 'modules/ui.py')
-rw-r--r--modules/ui.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/ui.py b/modules/ui.py
index f5df1ffe..6853485c 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)
@@ -480,6 +484,7 @@ def create_ui():
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")
+ aspect_ratio_dropdown = gr.Dropdown(value="🔓", choices=aspect_ratio_list(), interactive=True, type="value", elem_id="txt2img_ratio", show_label=False, label="Aspect Ratio")
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")
@@ -758,6 +763,7 @@ def create_ui():
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")
+ aspect_ratio_dropdown = gr.Dropdown(value="🔓", choices=aspect_ratio_list(), interactive=True, type="value", elem_id="img2img_ratio", show_label=False, label="Aspect Ratio")
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")