Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,29 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from gradio_client import Client
|
| 3 |
|
| 4 |
-
# Connect to
|
| 5 |
vton_client = Client("Kwai-Kolors/Kolors-Virtual-Try-On")
|
| 6 |
mesh_client = Client("tencent/Hunyuan3D-2.1")
|
| 7 |
|
| 8 |
def vton_to_3d(person_img, cloth_img):
|
| 9 |
-
# Step 1: Virtual Try-On (
|
| 10 |
vton_output = vton_client.predict(
|
| 11 |
-
person_img,
|
| 12 |
-
|
|
|
|
| 13 |
)
|
| 14 |
tryon_img = vton_output
|
| 15 |
|
| 16 |
-
# Step 2:
|
| 17 |
mesh_output = mesh_client.predict(
|
| 18 |
tryon_img,
|
| 19 |
-
api_name="/
|
| 20 |
)
|
| 21 |
|
|
|
|
| 22 |
return tryon_img, mesh_output
|
| 23 |
|
|
|
|
| 24 |
demo = gr.Interface(
|
| 25 |
fn=vton_to_3d,
|
| 26 |
inputs=[
|
|
@@ -29,11 +32,11 @@ demo = gr.Interface(
|
|
| 29 |
],
|
| 30 |
outputs=[
|
| 31 |
gr.Image(label="2D Try-On Result"),
|
| 32 |
-
gr.
|
| 33 |
],
|
| 34 |
-
title="
|
| 35 |
-
description="
|
| 36 |
)
|
| 37 |
|
| 38 |
if __name__ == "__main__":
|
| 39 |
-
demo.launch(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from gradio_client import Client
|
| 3 |
|
| 4 |
+
# Connect to Hugging Face Spaces
|
| 5 |
vton_client = Client("Kwai-Kolors/Kolors-Virtual-Try-On")
|
| 6 |
mesh_client = Client("tencent/Hunyuan3D-2.1")
|
| 7 |
|
| 8 |
def vton_to_3d(person_img, cloth_img):
|
| 9 |
+
# Step 1: Run Virtual Try-On (Space 1)
|
| 10 |
vton_output = vton_client.predict(
|
| 11 |
+
person_img,
|
| 12 |
+
cloth_img,
|
| 13 |
+
api_name="/vton" # confirmed API name for Kolors VTON
|
| 14 |
)
|
| 15 |
tryon_img = vton_output
|
| 16 |
|
| 17 |
+
# Step 2: Run 3D mesh generation (Space 2)
|
| 18 |
mesh_output = mesh_client.predict(
|
| 19 |
tryon_img,
|
| 20 |
+
api_name="/process" # confirmed API name for Hunyuan3D
|
| 21 |
)
|
| 22 |
|
| 23 |
+
# Return both outputs
|
| 24 |
return tryon_img, mesh_output
|
| 25 |
|
| 26 |
+
# Gradio UI
|
| 27 |
demo = gr.Interface(
|
| 28 |
fn=vton_to_3d,
|
| 29 |
inputs=[
|
|
|
|
| 32 |
],
|
| 33 |
outputs=[
|
| 34 |
gr.Image(label="2D Try-On Result"),
|
| 35 |
+
gr.Model3D(label="3D Mesh Output") # shows interactive 3D model
|
| 36 |
],
|
| 37 |
+
title="Virtual Try-On β 3D Avatar Generator",
|
| 38 |
+
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."
|
| 39 |
)
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
| 42 |
+
demo.launch()
|