Update app.py
Browse filestesting dropdown
app.py
CHANGED
|
@@ -520,7 +520,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 520 |
# default_prompts = get_prompts_by_gender(default_gender)
|
| 521 |
# default_prompt_keys = list(default_prompts.keys())
|
| 522 |
|
| 523 |
-
current_prompts = gr.State(default_prompts)
|
| 524 |
|
| 525 |
prompt = gr.Dropdown(
|
| 526 |
label="Select Prompt Theme",
|
|
@@ -552,23 +552,34 @@ with gr.Blocks(css=css) as demo:
|
|
| 552 |
# ]
|
| 553 |
|
| 554 |
|
| 555 |
-
def update_prompts_on_gender_change(gender):
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
|
| 562 |
-
gender_selector.change(
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 566 |
|
| 567 |
-
fn=update_prompts_on_gender_change,
|
| 568 |
-
inputs=gender_selector,
|
| 569 |
-
outputs=[prompt_dropdown, current_prompts]
|
| 570 |
-
)
|
| 571 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 572 |
|
| 573 |
style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME, visible=False)
|
| 574 |
aspect_ratio = gr.Dropdown(label="Output aspect ratio", choices=ASPECT_RATIO_LABELS, value=DEFAULT_ASPECT_RATIO, visible=False)
|
|
|
|
| 520 |
# default_prompts = get_prompts_by_gender(default_gender)
|
| 521 |
# default_prompt_keys = list(default_prompts.keys())
|
| 522 |
|
| 523 |
+
# current_prompts = gr.State(default_prompts)
|
| 524 |
|
| 525 |
prompt = gr.Dropdown(
|
| 526 |
label="Select Prompt Theme",
|
|
|
|
| 552 |
# ]
|
| 553 |
|
| 554 |
|
| 555 |
+
# def update_prompts_on_gender_change(gender):
|
| 556 |
+
# prompts = woman_prompts if gender == "woman" else man_prompts
|
| 557 |
+
# return [
|
| 558 |
+
# gr.update(choices=list(prompts.keys())),
|
| 559 |
+
# prompts # Update the stored prompts
|
| 560 |
+
# ]
|
| 561 |
|
| 562 |
+
# gender_selector.change(
|
| 563 |
+
# # fn=update_prompt_on_gender_change,
|
| 564 |
+
# # inputs=[gender_selector, selected_theme, prompt],
|
| 565 |
+
# # outputs=[prompt] + theme_buttons
|
| 566 |
+
|
| 567 |
+
# fn=update_prompts_on_gender_change,
|
| 568 |
+
# inputs=gender_selector,
|
| 569 |
+
# outputs=[prompt_dropdown, current_prompts]
|
| 570 |
+
# )
|
| 571 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 572 |
|
| 573 |
+
def update_prompt_dropdown_on_gender_change(gender):
|
| 574 |
+
theme_names = list(get_prompts_by_gender(gender).keys())
|
| 575 |
+
# Update dropdown choices to new gender’s themes and select first theme by default
|
| 576 |
+
return gr.update(choices=theme_names, value=theme_names[0])
|
| 577 |
+
|
| 578 |
+
gender_selector.change(
|
| 579 |
+
fn=update_prompt_dropdown_on_gender_change,
|
| 580 |
+
inputs=gender_selector,
|
| 581 |
+
outputs=prompt, # update the dropdown itself
|
| 582 |
+
)
|
| 583 |
|
| 584 |
style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME, visible=False)
|
| 585 |
aspect_ratio = gr.Dropdown(label="Output aspect ratio", choices=ASPECT_RATIO_LABELS, value=DEFAULT_ASPECT_RATIO, visible=False)
|