File size: 1,048 Bytes
cb430e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import subprocess
import os
import shutil

def run_rigging(input_model):
    # 1. Create a clean work folder
    if os.path.exists("temp_input"):
        shutil.rmtree("temp_input")
    os.makedirs("temp_input", exist_ok=True)
    
    # 2. Save your uploaded file into the input folder
    input_path = os.path.join("temp_input", "model.glb")
    shutil.copy(input_model.name, input_path)
    
    # 3. Trigger the Seed3D rigging script
    # We use subprocess to run the .sh file you dragged into the repo
    try:
        subprocess.run(["bash", "demo_rigging.sh"], check=True)
        # Seed3D usually saves results in a 'results' folder
        output_path = "results/rigging/model_rigged.glb" 
        return output_path
    except Exception as e:
        return f"Error during rigging: {str(e)}"

# This creates the "API Door" for your AI Studio app
demo = gr.Interface(
    fn=run_rigging,
    inputs=gr.File(label="Upload Model"),
    outputs=gr.File(label="Download Rigged Model"),
    api_name="rig" 
)

demo.launch()