Monikashyapa commited on
Commit
49749f5
Β·
verified Β·
1 Parent(s): cb4f363

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -1,26 +1,29 @@
1
  import gradio as gr
2
- from gradio_client import Client, handle_file
3
 
4
- # Connect to Spaces using gradio_client
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 (2D image)
10
  vton_output = vton_client.predict(
11
- person_img, cloth_img,
12
- api_name="/tryon" # verify via "Use via API" on the Space UI
 
13
  )
14
  tryon_img = vton_output
15
 
16
- # Step 2: Generate 3D mesh using the 2D try-on image
17
  mesh_output = mesh_client.predict(
18
  tryon_img,
19
- api_name="/predict" # verify via "Use via API" on the Space UI
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.File(label="3D Mesh Output (.glb/.obj/.ply)")
33
  ],
34
- title="2D Try-On β†’ 3D Mesh Pipeline",
35
- description="Uploads a person image and clothing image β†’ performs virtual try-on β†’ generates a 3D mesh."
36
  )
37
 
38
  if __name__ == "__main__":
39
- demo.launch(share=True) # Set share=True to create a public link
 
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()