Update app.py
Browse files
app.py
CHANGED
|
@@ -323,9 +323,33 @@ footer, [class*="footer"], [class*="api"], [class*="settings"] {
|
|
| 323 |
}
|
| 324 |
|
| 325 |
a[href*="api"], .api-button, #api-button {
|
| 326 |
-
display: none !important;
|
|
|
|
| 327 |
}
|
| 328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
'''
|
| 330 |
with gr.Blocks(css=css) as demo:
|
| 331 |
gr.Markdown(logo)
|
|
@@ -349,9 +373,24 @@ with gr.Blocks(css=css) as demo:
|
|
| 349 |
|
| 350 |
# with gr.Column(visible=False) as clear_button:
|
| 351 |
# remove_and_reupload = gr.ClearButton(value="Remove and upload new ones", components=files, size="sm")
|
| 352 |
-
prompt = gr.Textbox(
|
|
|
|
| 353 |
info="Try something like 'a photo of a man/woman img', 'img' is the trigger word.",
|
| 354 |
-
placeholder="A photo of a [man/woman img]..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
|
| 356 |
aspect_ratio = gr.Dropdown(label="Output aspect ratio", choices=ASPECT_RATIO_LABELS, value=DEFAULT_ASPECT_RATIO)
|
| 357 |
submit = gr.Button("GENERATE" , elem_id="generate_btn")
|
|
@@ -475,6 +514,28 @@ with gr.Blocks(css=css) as demo:
|
|
| 475 |
outputs=[gallery, usage_tips]
|
| 476 |
)
|
| 477 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
gr.Examples(
|
| 479 |
examples=get_example(),
|
| 480 |
inputs=[files, prompt, style, negative_prompt],
|
|
|
|
| 323 |
}
|
| 324 |
|
| 325 |
a[href*="api"], .api-button, #api-button {
|
| 326 |
+
display: none !important;
|
| 327 |
+
|
| 328 |
}
|
| 329 |
+
|
| 330 |
+
#prompt_suggestions_box {
|
| 331 |
+
background: white;
|
| 332 |
+
border: 2px solid #D46BCA;
|
| 333 |
+
padding: 15px;
|
| 334 |
+
border-radius: 10px;
|
| 335 |
+
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
|
| 336 |
+
position: fixed;
|
| 337 |
+
top: 20%;
|
| 338 |
+
left: 50%;
|
| 339 |
+
transform: translate(-50%, 0);
|
| 340 |
+
width: 40%;
|
| 341 |
+
z-index: 9999;
|
| 342 |
+
}
|
| 343 |
+
#suggested_prompts_btn {
|
| 344 |
+
background: #D46BCA !important;
|
| 345 |
+
color: white !important;
|
| 346 |
+
}
|
| 347 |
+
#close_prompt_box {
|
| 348 |
+
background: #553566 !important;
|
| 349 |
+
color: white !important;
|
| 350 |
+
width: 100%;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
'''
|
| 354 |
with gr.Blocks(css=css) as demo:
|
| 355 |
gr.Markdown(logo)
|
|
|
|
| 373 |
|
| 374 |
# with gr.Column(visible=False) as clear_button:
|
| 375 |
# remove_and_reupload = gr.ClearButton(value="Remove and upload new ones", components=files, size="sm")
|
| 376 |
+
prompt = gr.Textbox(
|
| 377 |
+
label="Prompt",
|
| 378 |
info="Try something like 'a photo of a man/woman img', 'img' is the trigger word.",
|
| 379 |
+
placeholder="A photo of a [man/woman img]..."
|
| 380 |
+
)
|
| 381 |
+
|
| 382 |
+
with gr.Row():
|
| 383 |
+
show_prompts_btn = gr.Button("💡 Suggested Prompts", elem_id="suggested_prompts_btn")
|
| 384 |
+
|
| 385 |
+
with gr.Box(visible=False, elem_id="prompt_suggestions_box") as prompt_suggestions:
|
| 386 |
+
gr.Markdown("### 🎯 Suggested Prompts")
|
| 387 |
+
prompt_buttons = [
|
| 388 |
+
gr.Button("A photo of a smiling woman img in a sunny park"),
|
| 389 |
+
gr.Button("A portrait of a man img in cinematic lighting"),
|
| 390 |
+
gr.Button("A studio photo of a woman img wearing glasses")
|
| 391 |
+
]
|
| 392 |
+
close_btn = gr.Button("❌ Close", elem_id="close_prompt_box")
|
| 393 |
+
|
| 394 |
style = gr.Dropdown(label="Style template", choices=STYLE_NAMES, value=DEFAULT_STYLE_NAME)
|
| 395 |
aspect_ratio = gr.Dropdown(label="Output aspect ratio", choices=ASPECT_RATIO_LABELS, value=DEFAULT_ASPECT_RATIO)
|
| 396 |
submit = gr.Button("GENERATE" , elem_id="generate_btn")
|
|
|
|
| 514 |
outputs=[gallery, usage_tips]
|
| 515 |
)
|
| 516 |
|
| 517 |
+
# Show the suggestions popup
|
| 518 |
+
show_prompts_btn.click(
|
| 519 |
+
lambda: gr.update(visible=True),
|
| 520 |
+
outputs=prompt_suggestions
|
| 521 |
+
)
|
| 522 |
+
|
| 523 |
+
# Close the popup
|
| 524 |
+
close_btn.click(
|
| 525 |
+
lambda: gr.update(visible=False),
|
| 526 |
+
outputs=prompt_suggestions
|
| 527 |
+
)
|
| 528 |
+
|
| 529 |
+
# When user clicks on a suggestion, fill the prompt textbox and close popup
|
| 530 |
+
for btn in prompt_buttons:
|
| 531 |
+
btn.click(
|
| 532 |
+
lambda text: (gr.update(value=text), gr.update(visible=False)),
|
| 533 |
+
inputs=None,
|
| 534 |
+
outputs=[prompt, prompt_suggestions],
|
| 535 |
+
_js=f"() => '{btn.value}'" # injects the button text
|
| 536 |
+
)
|
| 537 |
+
|
| 538 |
+
|
| 539 |
gr.Examples(
|
| 540 |
examples=get_example(),
|
| 541 |
inputs=[files, prompt, style, negative_prompt],
|