Spaces:
Build error
Build error
Commit
·
0ed20b9
1
Parent(s):
6025240
feat: Implement mask-based and Flux.1 fill development tab in app.py
Browse files- Added a new tab for mask-based and Flux.1 fill development, allowing users to upload person and condition images for virtual try-on.
- Introduced advanced options including inference steps, guidance scale, and random seed settings.
- Enhanced user experience with example images for both person and condition inputs.
- Updated the UI layout to improve accessibility and interaction for users.
app.py
CHANGED
|
@@ -395,7 +395,6 @@ HEADER = """
|
|
| 395 |
</div>
|
| 396 |
<br>
|
| 397 |
· This demo and our weights are only for Non-commercial Use. <br>
|
| 398 |
-
· You can try CatVTON in our <a href="https://huggingface.co/spaces/zhengchong/CatVTON">HuggingFace Space</a> or our <a href="http://120.76.142.206:8888">online demo</a> (run on 3090). <br>
|
| 399 |
· Thanks to <a href="https://huggingface.co/zero-gpu-explorers">ZeroGPU</a> for providing A100 for our <a href="https://huggingface.co/spaces/zhengchong/CatVTON">HuggingFace Space</a>. <br>
|
| 400 |
· SafetyChecker is set to filter NSFW content, but it may block normal results too. Please adjust the <span>`seed`</span> for normal outcomes.<br>
|
| 401 |
"""
|
|
@@ -534,7 +533,132 @@ def app_gradio():
|
|
| 534 |
],
|
| 535 |
result_image,
|
| 536 |
)
|
| 537 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 538 |
with gr.Tab("Mask-free & SD1.5"):
|
| 539 |
with gr.Row():
|
| 540 |
with gr.Column(scale=1, min_width=350):
|
|
@@ -654,70 +778,6 @@ def app_gradio():
|
|
| 654 |
result_image_p2p,
|
| 655 |
)
|
| 656 |
|
| 657 |
-
with gr.Tab("Mask-based & Flux.1 Fill Dev"):
|
| 658 |
-
with gr.Row():
|
| 659 |
-
with gr.Column(scale=1, min_width=350):
|
| 660 |
-
with gr.Row():
|
| 661 |
-
image_path_flux = gr.Image(
|
| 662 |
-
type="filepath",
|
| 663 |
-
interactive=True,
|
| 664 |
-
visible=False,
|
| 665 |
-
)
|
| 666 |
-
person_image_flux = gr.ImageEditor(
|
| 667 |
-
interactive=True, label="Person Image", type="filepath"
|
| 668 |
-
)
|
| 669 |
-
|
| 670 |
-
with gr.Row():
|
| 671 |
-
with gr.Column(scale=1, min_width=230):
|
| 672 |
-
cloth_image_flux = gr.Image(
|
| 673 |
-
interactive=True, label="Condition Image", type="filepath"
|
| 674 |
-
)
|
| 675 |
-
with gr.Column(scale=1, min_width=120):
|
| 676 |
-
gr.Markdown(
|
| 677 |
-
'<span style="color: #808080; font-size: small;">Two ways to provide Mask:<br>1. Upload the person image and use the `🖌️` above to draw the Mask (higher priority)<br>2. Select the `Try-On Cloth Type` to generate automatically </span>'
|
| 678 |
-
)
|
| 679 |
-
cloth_type = gr.Radio(
|
| 680 |
-
label="Try-On Cloth Type",
|
| 681 |
-
choices=["upper", "lower", "overall"],
|
| 682 |
-
value="upper",
|
| 683 |
-
)
|
| 684 |
-
|
| 685 |
-
submit_flux = gr.Button("Submit")
|
| 686 |
-
gr.Markdown(
|
| 687 |
-
'<center><span style="color: #FF0000">!!! Click only Once, Wait for Delay !!!</span></center>'
|
| 688 |
-
)
|
| 689 |
-
|
| 690 |
-
with gr.Accordion("Advanced Options", open=False):
|
| 691 |
-
num_inference_steps_flux = gr.Slider(
|
| 692 |
-
label="Inference Step", minimum=10, maximum=100, step=5, value=50
|
| 693 |
-
)
|
| 694 |
-
# Guidence Scale
|
| 695 |
-
guidance_scale_flux = gr.Slider(
|
| 696 |
-
label="CFG Strenth", minimum=0.0, maximum=7.5, step=0.5, value=2.5
|
| 697 |
-
)
|
| 698 |
-
# Random Seed
|
| 699 |
-
seed_flux = gr.Slider(
|
| 700 |
-
label="Seed", minimum=-1, maximum=10000, step=1, value=42
|
| 701 |
-
)
|
| 702 |
-
show_type = gr.Radio(
|
| 703 |
-
label="Show Type",
|
| 704 |
-
choices=["result only", "input & result", "input & mask & result"],
|
| 705 |
-
value="input & mask & result",
|
| 706 |
-
)
|
| 707 |
-
|
| 708 |
-
with gr.Column(scale=2, min_width=500):
|
| 709 |
-
result_image_flux = gr.Image(interactive=False, label="Result")
|
| 710 |
-
|
| 711 |
-
image_path_flux.change(
|
| 712 |
-
person_example_fn, inputs=image_path_flux, outputs=person_image_flux
|
| 713 |
-
)
|
| 714 |
-
|
| 715 |
-
submit_flux.click(
|
| 716 |
-
submit_function_flux,
|
| 717 |
-
[person_image_flux, cloth_image_flux, cloth_type, num_inference_steps_flux, guidance_scale_flux, seed_flux, show_type],
|
| 718 |
-
result_image_flux,
|
| 719 |
-
)
|
| 720 |
-
|
| 721 |
demo.queue().launch(share=True, show_error=True)
|
| 722 |
|
| 723 |
|
|
|
|
| 395 |
</div>
|
| 396 |
<br>
|
| 397 |
· This demo and our weights are only for Non-commercial Use. <br>
|
|
|
|
| 398 |
· Thanks to <a href="https://huggingface.co/zero-gpu-explorers">ZeroGPU</a> for providing A100 for our <a href="https://huggingface.co/spaces/zhengchong/CatVTON">HuggingFace Space</a>. <br>
|
| 399 |
· SafetyChecker is set to filter NSFW content, but it may block normal results too. Please adjust the <span>`seed`</span> for normal outcomes.<br>
|
| 400 |
"""
|
|
|
|
| 533 |
],
|
| 534 |
result_image,
|
| 535 |
)
|
| 536 |
+
|
| 537 |
+
with gr.Tab("Mask-based & Flux.1 Fill Dev"):
|
| 538 |
+
with gr.Row():
|
| 539 |
+
with gr.Column(scale=1, min_width=350):
|
| 540 |
+
with gr.Row():
|
| 541 |
+
image_path_flux = gr.Image(
|
| 542 |
+
type="filepath",
|
| 543 |
+
interactive=True,
|
| 544 |
+
visible=False,
|
| 545 |
+
)
|
| 546 |
+
person_image_flux = gr.ImageEditor(
|
| 547 |
+
interactive=True, label="Person Image", type="filepath"
|
| 548 |
+
)
|
| 549 |
+
|
| 550 |
+
with gr.Row():
|
| 551 |
+
with gr.Column(scale=1, min_width=230):
|
| 552 |
+
cloth_image_flux = gr.Image(
|
| 553 |
+
interactive=True, label="Condition Image", type="filepath"
|
| 554 |
+
)
|
| 555 |
+
with gr.Column(scale=1, min_width=120):
|
| 556 |
+
gr.Markdown(
|
| 557 |
+
'<span style="color: #808080; font-size: small;">Two ways to provide Mask:<br>1. Upload the person image and use the `🖌️` above to draw the Mask (higher priority)<br>2. Select the `Try-On Cloth Type` to generate automatically </span>'
|
| 558 |
+
)
|
| 559 |
+
cloth_type = gr.Radio(
|
| 560 |
+
label="Try-On Cloth Type",
|
| 561 |
+
choices=["upper", "lower", "overall"],
|
| 562 |
+
value="upper",
|
| 563 |
+
)
|
| 564 |
+
|
| 565 |
+
submit_flux = gr.Button("Submit")
|
| 566 |
+
gr.Markdown(
|
| 567 |
+
'<center><span style="color: #FF0000">!!! Click only Once, Wait for Delay !!!</span></center>'
|
| 568 |
+
)
|
| 569 |
+
|
| 570 |
+
with gr.Accordion("Advanced Options", open=False):
|
| 571 |
+
num_inference_steps_flux = gr.Slider(
|
| 572 |
+
label="Inference Step", minimum=10, maximum=100, step=5, value=50
|
| 573 |
+
)
|
| 574 |
+
# Guidence Scale
|
| 575 |
+
guidance_scale_flux = gr.Slider(
|
| 576 |
+
label="CFG Strenth", minimum=0.0, maximum=7.5, step=0.5, value=2.5
|
| 577 |
+
)
|
| 578 |
+
# Random Seed
|
| 579 |
+
seed_flux = gr.Slider(
|
| 580 |
+
label="Seed", minimum=-1, maximum=10000, step=1, value=42
|
| 581 |
+
)
|
| 582 |
+
show_type = gr.Radio(
|
| 583 |
+
label="Show Type",
|
| 584 |
+
choices=["result only", "input & result", "input & mask & result"],
|
| 585 |
+
value="input & mask & result",
|
| 586 |
+
)
|
| 587 |
+
|
| 588 |
+
with gr.Column(scale=2, min_width=500):
|
| 589 |
+
result_image_flux = gr.Image(interactive=False, label="Result")
|
| 590 |
+
|
| 591 |
+
with gr.Column(scale=2, min_width=500):
|
| 592 |
+
result_image_p2p = gr.Image(interactive=False, label="Result")
|
| 593 |
+
with gr.Row():
|
| 594 |
+
# Photo Examples
|
| 595 |
+
root_path = "resource/demo/example"
|
| 596 |
+
with gr.Column():
|
| 597 |
+
gr.Examples(
|
| 598 |
+
examples=[
|
| 599 |
+
os.path.join(root_path, "person", "men", _)
|
| 600 |
+
for _ in os.listdir(os.path.join(root_path, "person", "men"))
|
| 601 |
+
],
|
| 602 |
+
examples_per_page=4,
|
| 603 |
+
inputs=image_path_flux,
|
| 604 |
+
label="Person Examples ①",
|
| 605 |
+
)
|
| 606 |
+
gr.Examples(
|
| 607 |
+
examples=[
|
| 608 |
+
os.path.join(root_path, "person", "women", _)
|
| 609 |
+
for _ in os.listdir(os.path.join(root_path, "person", "women"))
|
| 610 |
+
],
|
| 611 |
+
examples_per_page=4,
|
| 612 |
+
inputs=image_path_flux,
|
| 613 |
+
label="Person Examples ②",
|
| 614 |
+
)
|
| 615 |
+
gr.Markdown(
|
| 616 |
+
'<span style="color: #808080; font-size: small;">*Person examples come from the demos of <a href="https://huggingface.co/spaces/levihsu/OOTDiffusion">OOTDiffusion</a> and <a href="https://www.outfitanyone.org">OutfitAnyone</a>. </span>'
|
| 617 |
+
)
|
| 618 |
+
with gr.Column():
|
| 619 |
+
gr.Examples(
|
| 620 |
+
examples=[
|
| 621 |
+
os.path.join(root_path, "condition", "upper", _)
|
| 622 |
+
for _ in os.listdir(os.path.join(root_path, "condition", "upper"))
|
| 623 |
+
],
|
| 624 |
+
examples_per_page=4,
|
| 625 |
+
inputs=cloth_image_flux,
|
| 626 |
+
label="Condition Upper Examples",
|
| 627 |
+
)
|
| 628 |
+
gr.Examples(
|
| 629 |
+
examples=[
|
| 630 |
+
os.path.join(root_path, "condition", "overall", _)
|
| 631 |
+
for _ in os.listdir(os.path.join(root_path, "condition", "overall"))
|
| 632 |
+
],
|
| 633 |
+
examples_per_page=4,
|
| 634 |
+
inputs=cloth_image_flux,
|
| 635 |
+
label="Condition Overall Examples",
|
| 636 |
+
)
|
| 637 |
+
condition_person_exm = gr.Examples(
|
| 638 |
+
examples=[
|
| 639 |
+
os.path.join(root_path, "condition", "person", _)
|
| 640 |
+
for _ in os.listdir(os.path.join(root_path, "condition", "person"))
|
| 641 |
+
],
|
| 642 |
+
examples_per_page=4,
|
| 643 |
+
inputs=cloth_image_flux,
|
| 644 |
+
label="Condition Reference Person Examples",
|
| 645 |
+
)
|
| 646 |
+
gr.Markdown(
|
| 647 |
+
'<span style="color: #808080; font-size: small;">*Condition examples come from the Internet. </span>'
|
| 648 |
+
)
|
| 649 |
+
|
| 650 |
+
|
| 651 |
+
image_path_flux.change(
|
| 652 |
+
person_example_fn, inputs=image_path_flux, outputs=person_image_flux
|
| 653 |
+
)
|
| 654 |
+
|
| 655 |
+
submit_flux.click(
|
| 656 |
+
submit_function_flux,
|
| 657 |
+
[person_image_flux, cloth_image_flux, cloth_type, num_inference_steps_flux, guidance_scale_flux, seed_flux, show_type],
|
| 658 |
+
result_image_flux,
|
| 659 |
+
)
|
| 660 |
+
|
| 661 |
+
|
| 662 |
with gr.Tab("Mask-free & SD1.5"):
|
| 663 |
with gr.Row():
|
| 664 |
with gr.Column(scale=1, min_width=350):
|
|
|
|
| 778 |
result_image_p2p,
|
| 779 |
)
|
| 780 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 781 |
demo.queue().launch(share=True, show_error=True)
|
| 782 |
|
| 783 |
|