FAW-AI-APP / virtualtryon_tab.py
JarvisLabs's picture
Update virtualtryon_tab.py
69f3a9a verified
from src.rep_api import virtual_try_on
import gradio as gr
def create_virtualtryon_tab():
with gr.TabItem("Virtual Try-on",id="virtual_tryon"):
with gr.Accordion("HowTo",open=False):
gr.Markdown("""
# Virtual Try-On Workflow バーチャル試着ワークフロー \n
・1 Select base image ベース画像を選択します。 \n
・2 Select the cloth image 服の画像を選択します \n
・3 Add description 説明を追加します \n
・4 Click Try-ON トライオンをクリックします。 \n
""")
gr.Image(value="HowTo/Vtron_Abstract.png",interactive=False)
with gr.Row():
with gr.Column():
category = gr.Dropdown(["upper_body", "lower_body", "dresses"], label="Category", value="upper_body")
human_img = gr.Image(label="Human Image")
with gr.Accordion("Settings", open=False):
crop = gr.Checkbox(label="Crop", value=True)
seed = gr.Number(label="Seed", value=42)
steps = gr.Number(label="Steps", value=30)
with gr.Accordion("Example People", open=False):
human_examples = gr.Examples(
examples=[
["Test_images/Woman_1.png"],
["Test_images/prompt_support_examples/Man_1.png"],
["Test_images/Woman_2.png"],
["Test_images/prompt_support_examples/Man_2.png"],
["Test_images/Woman_3.png"],
["Test_images/man_1.png"],
["Test_images/Woman_4.png"],
["Test_images/Woman_5.png"],
["Test_images/anime_woman_1.png"],
["Test_images/anime_woman_2.png"],
["Test_images/anime_woman_3.png"],
["Test_images/Jump.png"],
],
inputs=[human_img],
examples_per_page=24
)
with gr.Column():
garm_img = gr.Image(label="Garment Image")
garment_des = gr.Textbox(label="Garment Description")
with gr.Accordion("Example Clothes", open=True):
cloth_examples = gr.Examples(
examples=[
["Test_images/pink_jumper.png","pink jumper","upper_body"],
["Test_images/Suit_1.png","Suit","upper_body"],
["Test_images/Suit_2.png","Suit","upper_body"],
["Test_images/Suit_4.png","Suit","upper_body"],
["Test_images/Jacket_1.png","Colorfull leather jacket","upper_body"],
["Test_images/Jacket_2.png","White jacket","upper_body"],
["Test_images/Shirt_1.png","Shirt","upper_body"],
["Test_images/dress_2.png","dress","dresses"],
["Test_images/dress_1.png","dress","dresses"],
["Test_images/dress_3.png","pink dress","dresses"],
["Test_images/dress_4.png","red dress","dresses"],
["Test_images/dress_5.png","golden dress","dresses"],
["Test_images/dress_6.png","brown dress","dresses"],
["Test_images/dress_7.png","pink dress","dresses"],
["Test_images/Suit_4.png","one-piece suit","upper_body"],
],
inputs=[garm_img,garment_des,category],
examples_per_page=8
)
with gr.Row():
tryon_btn = gr.Button("Try-on",elem_id="gen-btn")
with gr.Row():
tryon_out = gr.Image(label="Output", type="filepath",elem_id="output_image")
with gr.Row(): #Move gen out row
move_to_cnmk =gr.Button("Move to Control net mockup ")
move_to_relight= gr.Button("Move to Relight")
with gr.Row():
tryon_examples = gr.Examples(
examples=[
["Test_images/Woman_4.png",True,"Test_images/example_outputs/test001.jpg","Shirt","upper_body","Test_images/example_outputs/test001_Output.jpg"],
["Test_images/example_outputs/input_1.webp",True,"Test_images/pink_jumper.png","pink jumper","upper_body","Test_images/example_outputs/input_1_VTO_Pink.jpg"],
["Test_images/example_outputs/input_3.png",True,"Test_images/Jacket_2.png","jacket","upper_body","Test_images/example_outputs/input_3_VTO_whiteJacket.jpg"],
["Test_images/example_outputs/input_4.png",True,"Test_images/Jacket_1.png","colorfull leather jacket","upper_body","Test_images/example_outputs/Input_4_VTO_ColorFullJacket.jpg"],
["Test_images/example_outputs/input_4.png",True,"Test_images/dress_1.png","dress","dresses","Test_images/example_outputs/Input_3_VTO_LoritaDress.jpg"],
["Test_images/example_outputs/input_4.png",True,"Test_images/Shirt_1.png"," Shirt","upper_body","Test_images/example_outputs/Input_3_VTO_Shirt.jpg"],
],
inputs=[human_img,crop,garm_img,garment_des,category,tryon_out],
)
tryon_btn.click(virtual_try_on, inputs=[crop, seed, steps, category, garm_img, human_img,garment_des],outputs=tryon_out)
return human_img,tryon_out,move_to_cnmk,move_to_relight