Spaces:
Sleeping
Sleeping
JarvisLabs
commited on
Commit
•
02118aa
1
Parent(s):
ae0f347
Upload 2 files
Browse files- app.py +22 -20
- virtualtryon_tab.py +31 -0
app.py
CHANGED
@@ -1,20 +1,22 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from gen_tab import create_gen_tab
|
3 |
-
from train_tab import create_train_tab
|
4 |
-
from
|
5 |
-
import
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from gen_tab import create_gen_tab
|
3 |
+
from train_tab import create_train_tab
|
4 |
+
from virtualtryon_tab import create_virtualtryon_tab
|
5 |
+
from dotenv import load_dotenv, find_dotenv
|
6 |
+
import os
|
7 |
+
|
8 |
+
_ = load_dotenv(find_dotenv())
|
9 |
+
with gr.Blocks(theme=gr.themes.Soft(
|
10 |
+
radius_size=gr.themes.sizes.radius_none,
|
11 |
+
primary_hue=gr.themes.colors.emerald, secondary_hue=gr.themes.colors.green
|
12 |
+
|
13 |
+
)) as demo:
|
14 |
+
with gr.Tabs() as tabs:
|
15 |
+
create_gen_tab()
|
16 |
+
create_train_tab()
|
17 |
+
create_virtualtryon_tab()
|
18 |
+
# with gr.TabItem("Theme builder"):
|
19 |
+
# gr.themes.builder()
|
20 |
+
|
21 |
+
|
22 |
+
demo.launch(share=True,debug=True) #,auth=[("username", "password"),(os.getenv("APP_USER"),os.getenv("APP_PW"))])
|
virtualtryon_tab.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from src.rep_api import virtual_try_on
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
|
5 |
+
def create_virtualtryon_tab():
|
6 |
+
with gr.TabItem("Virtual Try-on",id="virtual_tryon"):
|
7 |
+
with gr.Row():
|
8 |
+
with gr.Column():
|
9 |
+
human_img = gr.Image(label="Human Image")
|
10 |
+
crop = gr.Checkbox(label="Crop", value=False)
|
11 |
+
seed = gr.Number(label="Seed", value=42)
|
12 |
+
steps = gr.Number(label="Steps", value=30)
|
13 |
+
with gr.Column():
|
14 |
+
garm_img = gr.Image(label="Garment Image")
|
15 |
+
category = gr.Dropdown(["upper_body", "lower_body", "full_body"], label="Category", value="upper_body")
|
16 |
+
garment_des = gr.Textbox(label="Garment Description")
|
17 |
+
with gr.Row():
|
18 |
+
tryon_btn = gr.Button("Try-on")
|
19 |
+
with gr.Row():
|
20 |
+
tryon_out = gr.Image(label="Output", type="filepath")
|
21 |
+
with gr.Row():
|
22 |
+
examples = gr.Examples(
|
23 |
+
examples=[
|
24 |
+
[ False, 42, 30, "upper_body", "Test_images/pink_jumper.png", "Test_images/person_1.jpg","pink jumper"],
|
25 |
+
[ True, 100, 50, "upper_body", "Test_images/Suit_2.png", "Test_images/person_2.jpg","Suit"],
|
26 |
+
# [ False, 7, 20, "full_body", "path/to/garment_img3.jpg", "path/to/human_img3.jpg","Black Suit"]
|
27 |
+
],
|
28 |
+
inputs=[ crop, seed, steps, category, garm_img,human_img, garment_des]
|
29 |
+
)
|
30 |
+
|
31 |
+
tryon_btn.click(virtual_try_on, inputs=[crop, seed, steps, category, garm_img, human_img,garment_des],outputs=tryon_out)
|