File size: 1,290 Bytes
edfb9ce
49749f5
edfb9ce
49749f5
edfb9ce
 
 
 
49749f5
edfb9ce
49749f5
 
 
edfb9ce
 
 
49749f5
edfb9ce
 
49749f5
edfb9ce
 
49749f5
edfb9ce
 
49749f5
edfb9ce
 
 
 
 
 
 
 
49749f5
edfb9ce
49749f5
 
edfb9ce
 
 
49749f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import gradio as gr
from gradio_client import Client

# Connect to Hugging Face Spaces
vton_client = Client("Kwai-Kolors/Kolors-Virtual-Try-On")
mesh_client = Client("tencent/Hunyuan3D-2.1")

def vton_to_3d(person_img, cloth_img):
    # Step 1: Run Virtual Try-On (Space 1)
    vton_output = vton_client.predict(
        person_img,
        cloth_img,
        api_name="/vton"   # confirmed API name for Kolors VTON
    )
    tryon_img = vton_output

    # Step 2: Run 3D mesh generation (Space 2)
    mesh_output = mesh_client.predict(
        tryon_img,
        api_name="/process"   # confirmed API name for Hunyuan3D
    )

    # Return both outputs
    return tryon_img, mesh_output

# Gradio UI
demo = gr.Interface(
    fn=vton_to_3d,
    inputs=[
        gr.Image(type="filepath", label="Person Image"),
        gr.Image(type="filepath", label="Cloth Image")
    ],
    outputs=[
        gr.Image(label="2D Try-On Result"),
        gr.Model3D(label="3D Mesh Output")  # shows interactive 3D model
    ],
    title="Virtual Try-On → 3D Avatar Generator",
    description="Upload a person image and a clothing image. The system first performs virtual try-on using Kolors VTON, then converts the result into a 3D mesh using Hunyuan3D."
)

if __name__ == "__main__":
    demo.launch()