Update app.py
Browse filestesting dropdown
app.py
CHANGED
|
@@ -103,9 +103,9 @@ def generate_image(
|
|
| 103 |
):
|
| 104 |
#added
|
| 105 |
prompts = get_prompts_by_gender(gender)
|
| 106 |
-
prompt = prompts.get(
|
| 107 |
if prompt is None:
|
| 108 |
-
raise gr.Error(f"Prompt theme '{
|
| 109 |
#
|
| 110 |
if use_doodle:
|
| 111 |
sketch_image = sketch_image["composite"]
|
|
@@ -542,9 +542,9 @@ with gr.Blocks(css=css) as demo:
|
|
| 542 |
pass
|
| 543 |
|
| 544 |
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
# prompts = get_prompts_by_gender(gender)
|
| 549 |
# return [
|
| 550 |
# gr.update(choices=list(prompts.keys()), value=list(prompts.keys())[0]),
|
|
@@ -559,10 +559,11 @@ with gr.Blocks(css=css) as demo:
|
|
| 559 |
# prompts # Update the stored prompts
|
| 560 |
# ]
|
| 561 |
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
|
|
|
| 566 |
|
| 567 |
# fn=update_prompts_on_gender_change,
|
| 568 |
# inputs=gender_selector,
|
|
@@ -570,16 +571,15 @@ with gr.Blocks(css=css) as demo:
|
|
| 570 |
# )
|
| 571 |
|
| 572 |
|
| 573 |
-
def update_prompt_dropdown_on_gender_change(gender):
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
|
| 578 |
-
gender_selector.change(
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 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)
|
|
|
|
| 103 |
):
|
| 104 |
#added
|
| 105 |
prompts = get_prompts_by_gender(gender)
|
| 106 |
+
prompt = prompts.get(prompt_theme)
|
| 107 |
if prompt is None:
|
| 108 |
+
raise gr.Error(f"Prompt theme '{prompt_theme}' not found for gender '{gender}'")
|
| 109 |
#
|
| 110 |
if use_doodle:
|
| 111 |
sketch_image = sketch_image["composite"]
|
|
|
|
| 542 |
pass
|
| 543 |
|
| 544 |
|
| 545 |
+
def update_prompt_dropdown(gender):
|
| 546 |
+
prompts = list(get_prompts_by_gender(gender).values())
|
| 547 |
+
return gr.update(choices=prompts, value=prompts[0]) # sets default to first
|
| 548 |
# prompts = get_prompts_by_gender(gender)
|
| 549 |
# return [
|
| 550 |
# gr.update(choices=list(prompts.keys()), value=list(prompts.keys())[0]),
|
|
|
|
| 559 |
# prompts # Update the stored prompts
|
| 560 |
# ]
|
| 561 |
|
| 562 |
+
gender_selector.change(
|
| 563 |
+
fn=update_prompt_dropdown,
|
| 564 |
+
inputs=gender_selector,
|
| 565 |
+
outputs=prompt
|
| 566 |
+
)
|
| 567 |
|
| 568 |
# fn=update_prompts_on_gender_change,
|
| 569 |
# inputs=gender_selector,
|
|
|
|
| 571 |
# )
|
| 572 |
|
| 573 |
|
| 574 |
+
# def update_prompt_dropdown_on_gender_change(gender):
|
| 575 |
+
# theme_names = list(get_prompts_by_gender(gender).keys())
|
| 576 |
+
# # Update dropdown choices to new gender’s themes and select first theme by default
|
| 577 |
+
# return gr.update(choices=theme_names, value=theme_names[0])
|
| 578 |
|
| 579 |
+
# gender_selector.change(
|
| 580 |
+
# fn=update_prompt_dropdown_on_gender_change,
|
| 581 |
+
# inputs=gender_selector,
|
| 582 |
+
# outputs=prompt, # update the dropdown itself )
|
|
|
|
| 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)
|