Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from warp_design_on_dress import run_design_warp_on_dress
|
3 |
+
from PIL import Image
|
4 |
+
import os
|
5 |
+
|
6 |
+
def gradio_tryon(dress_img, design_img):
|
7 |
+
os.makedirs("input", exist_ok=True)
|
8 |
+
os.makedirs("output", exist_ok=True)
|
9 |
+
|
10 |
+
dress_path = "input/dress.jpg"
|
11 |
+
design_path = "input/design.jpg"
|
12 |
+
|
13 |
+
dress_img.save(dress_path)
|
14 |
+
design_img.save(design_path)
|
15 |
+
|
16 |
+
result_path = run_design_warp_on_dress(
|
17 |
+
dress_path, design_path,
|
18 |
+
gmm_ckpt="checkpoints/gmm_final.pth",
|
19 |
+
tom_ckpt="checkpoints/tom_final.pth",
|
20 |
+
output_dir="output"
|
21 |
+
)
|
22 |
+
|
23 |
+
return Image.open(result_path)
|
24 |
+
|
25 |
+
gr.Interface(
|
26 |
+
fn=gradio_tryon,
|
27 |
+
inputs=[
|
28 |
+
gr.Image(label="Dress Image", type="pil"),
|
29 |
+
gr.Image(label="Design to Warp", type="pil")
|
30 |
+
],
|
31 |
+
outputs=gr.Image(label="Warped Design Output"),
|
32 |
+
title="🎨 Design Warping on Dress using CP-VTON+",
|
33 |
+
description="Upload a dress photo and a design. The model warps and blends the design onto the dress realistically."
|
34 |
+
).launch()
|