Spaces:
Running
on
Zero
Running
on
Zero
Update app_local.py
Browse files- app_local.py +89 -90
app_local.py
CHANGED
|
@@ -525,101 +525,100 @@ with gr.Blocks(title="'Qwen Image Edit' Model Playground & Showcase [4-Step Ligh
|
|
| 525 |
object_fit="contain",
|
| 526 |
container=True
|
| 527 |
)
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
update_preset_button = gr.Button("Update Preset", variant="secondary", visible=False)
|
| 554 |
-
reset_button = gr.Button("Reset Presets", variant="stop", visible=False)
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
# Add prompt preview component
|
| 559 |
-
prompt_preview = gr.Textbox(
|
| 560 |
-
label="📋 Prompt Preview",
|
| 561 |
-
interactive=False,
|
| 562 |
-
lines=6,
|
| 563 |
-
max_lines=10,
|
| 564 |
-
value="Enter a base prompt and select a preset above to see how your prompt will be modified for batch generation.",
|
| 565 |
-
placeholder="Prompt preview will appear here..."
|
| 566 |
-
)
|
| 567 |
-
|
| 568 |
-
rewrite_toggle = gr.Checkbox(
|
| 569 |
-
label="Additional Prompt Enhancement",
|
| 570 |
-
info="Setting this to true will pass the basic prompt(s) generated via the static preset template to a secondary LLM tasked with improving the overall cohesiveness and details of the final generation prompt.",
|
| 571 |
-
value=True,
|
| 572 |
-
interactive=True
|
| 573 |
-
)
|
| 574 |
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
minimum=1,
|
| 611 |
-
maximum=
|
| 612 |
step=1,
|
| 613 |
-
value=
|
| 614 |
-
interactive=True
|
| 615 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 616 |
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
)
|
| 623 |
|
| 624 |
|
| 625 |
def show_preset_editor(preset_type):
|
|
|
|
| 525 |
object_fit="contain",
|
| 526 |
container=True
|
| 527 |
)
|
| 528 |
+
with gr.Row():
|
| 529 |
+
with gr.Column(scale=1):
|
| 530 |
+
prompt = gr.Textbox(
|
| 531 |
+
label="Edit Instructions / Base Prompt",
|
| 532 |
+
placeholder="e.g. Replace the background with a beach sunset... When a preset is selected, use as the base prompt, e.g. the lamborghini",
|
| 533 |
+
lines=2,
|
| 534 |
+
max_lines=4,
|
| 535 |
+
scale=2
|
| 536 |
+
)
|
| 537 |
+
|
| 538 |
+
preset_dropdown = gr.Dropdown(
|
| 539 |
+
choices=get_preset_choices(),
|
| 540 |
+
value=None,
|
| 541 |
+
label="Preset Batch Generation",
|
| 542 |
+
interactive=True
|
| 543 |
+
)
|
| 544 |
+
# Add editable preset prompts (initially hidden)
|
| 545 |
+
preset_editor = gr.Group(visible=False)
|
| 546 |
+
with preset_editor:
|
| 547 |
+
gr.Markdown("### 🎨 Edit Preset Prompts")
|
| 548 |
+
preset_prompt_1 = gr.Textbox(label="Prompt 1", lines=1, value="")
|
| 549 |
+
preset_prompt_2 = gr.Textbox(label="Prompt 2", lines=1, value="")
|
| 550 |
+
preset_prompt_3 = gr.Textbox(label="Prompt 3", lines=1, value="")
|
| 551 |
+
preset_prompt_4 = gr.Textbox(label="Prompt 4", lines=1, value="")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 552 |
|
| 553 |
+
update_preset_button = gr.Button("Update Preset", variant="secondary", visible=False)
|
| 554 |
+
reset_button = gr.Button("Reset Presets", variant="stop", visible=False)
|
| 555 |
+
|
| 556 |
+
|
| 557 |
+
|
| 558 |
+
# Add prompt preview component
|
| 559 |
+
prompt_preview = gr.Textbox(
|
| 560 |
+
label="📋 Prompt Preview",
|
| 561 |
+
interactive=False,
|
| 562 |
+
lines=6,
|
| 563 |
+
max_lines=10,
|
| 564 |
+
value="Enter a base prompt and select a preset above to see how your prompt will be modified for batch generation.",
|
| 565 |
+
placeholder="Prompt preview will appear here..."
|
| 566 |
+
)
|
| 567 |
+
|
| 568 |
+
rewrite_toggle = gr.Checkbox(
|
| 569 |
+
label="Additional Prompt Enhancement",
|
| 570 |
+
info="Setting this to true will pass the basic prompt(s) generated via the static preset template to a secondary LLM tasked with improving the overall cohesiveness and details of the final generation prompt.",
|
| 571 |
+
value=True,
|
| 572 |
+
interactive=True
|
| 573 |
+
)
|
| 574 |
+
|
| 575 |
+
run_button = gr.Button(
|
| 576 |
+
"Generate Edit(s)",
|
| 577 |
+
variant="primary"
|
| 578 |
+
)
|
| 579 |
+
with gr.Accordion("Advanced Parameters", open=False):
|
| 580 |
+
with gr.Row():
|
| 581 |
+
seed = gr.Slider(
|
| 582 |
+
label="Seed",
|
| 583 |
+
minimum=0,
|
| 584 |
+
maximum=MAX_SEED,
|
| 585 |
+
step=1,
|
| 586 |
+
value=42
|
| 587 |
+
)
|
| 588 |
+
randomize_seed = gr.Checkbox(
|
| 589 |
+
label="Random Seed",
|
| 590 |
+
value=True
|
| 591 |
+
)
|
| 592 |
+
with gr.Row():
|
| 593 |
+
true_guidance_scale = gr.Slider(
|
| 594 |
+
label="True CFG Scale",
|
| 595 |
+
minimum=1.0,
|
| 596 |
+
maximum=10.0,
|
| 597 |
+
step=0.1,
|
| 598 |
+
value=1.1
|
| 599 |
+
)
|
| 600 |
+
num_inference_steps = gr.Slider(
|
| 601 |
+
label="Inference Steps",
|
| 602 |
minimum=1,
|
| 603 |
+
maximum=16,
|
| 604 |
step=1,
|
| 605 |
+
value=3
|
|
|
|
| 606 |
)
|
| 607 |
+
|
| 608 |
+
num_images_per_prompt = gr.Slider(
|
| 609 |
+
label="Output Count (Manual)",
|
| 610 |
+
minimum=1,
|
| 611 |
+
maximum=4,
|
| 612 |
+
step=1,
|
| 613 |
+
value=2,
|
| 614 |
+
interactive=True
|
| 615 |
+
)
|
| 616 |
|
| 617 |
+
with gr.Column(scale=2):
|
| 618 |
+
prompt_info = gr.Markdown(
|
| 619 |
+
value="<div style='padding:15px; margin-top:15px'>"
|
| 620 |
+
"Hint: depending on the original image, prompt quality, and complexity, you can often get away with 3 steps, even 2 steps without much loss in quality. </div>"
|
| 621 |
+
)
|
|
|
|
| 622 |
|
| 623 |
|
| 624 |
def show_preset_editor(preset_type):
|