allow tuple for dropdowns

This commit is contained in:
Vladimir Mandic
2023-10-10 07:54:59 -04:00
parent 22405a845a
commit 188fb1efcd
5 changed files with 10 additions and 14 deletions
-4
View File
@@ -543,7 +543,6 @@ def create_ui(startup_timer = None):
negative_token_button.click(fn=wrap_queued_call(update_token_counter), inputs=[txt2img_negative_prompt, steps], outputs=[negative_token_counter])
ui_extra_networks.setup_ui(extra_networks_ui, txt2img_gallery)
# log.debug(f'UI interface: tab=txt2img batch={show_batch.value} seed={show_seed.value} advanced={show_advanced.value} second_pass={show_second_pass.value}')
timer.startup.record("ui-txt2img")
@@ -674,9 +673,6 @@ def create_ui(startup_timer = None):
scale_by.release(**on_change_args)
button_update_resize_to.click(**on_change_args)
# the code below is meant to update the resolution label after the image in the image selection UI has changed.
# as it is now the event keeps firing continuously for inpaint edits, which ruins the page with constant requests.
# I assume this must be a gradio bug and for now we'll just do it for non-inpaint inputs.
for component in [init_img, sketch]:
component.change(fn=lambda: None, _js="updateImg2imgResizeToTextAfterChangingImage", inputs=[], outputs=[], show_progress=False)
+6 -2
View File
@@ -72,10 +72,14 @@ class UiLoadsave:
apply_field(x, 'value')
if type(x) == gr.Dropdown:
def check_dropdown(val):
if x.choices is None:
errors.log.warning(f'UI: path={path} value={getattr(x, "value", None)}, choices={getattr(x, "choices", None)}')
return False
choices = [c[0] for c in x.choices] if type(x.choices[0]) == tuple else x.choices
if getattr(x, 'multiselect', False):
return all(value in x.choices for value in val)
return all(value in choices for value in val)
else:
return val in x.choices
return val in choices
apply_field(x, 'value', check_dropdown, getattr(x, 'init_field', None))
def check_tab_id(tab_id):