Spaces:
Sleeping
Sleeping
| 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() | |