File size: 1,565 Bytes
cb430e6
 
0408c90
 
cb430e6
 
0408c90
 
 
 
 
 
 
cb430e6
0408c90
 
 
 
 
 
 
 
 
 
 
 
 
 
cb430e6
0408c90
 
cb430e6
0408c90
cb430e6
0408c90
 
 
 
 
 
 
 
cb430e6
0408c90
cb430e6
 
 
0408c90
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import gradio as gr
import os
import subprocess
import sys
import shutil

# 1. FORCE PYTHON TO SEE YOUR UPLOADED FOLDERS
# This fixes the 'No module named third_partys' error
current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(current_dir)
sys.path.append(os.path.join(current_dir, "skeleton"))
sys.path.append(os.path.join(current_dir, "skinning"))

def run_rigging(input_model):
    # 2. MANUALLY CREATE MISSING FOLDERS
    # This fixes the 'No such file or directory' errors in the .sh script
    folders = [
        "results/skel_results",
        "results/skin_results/generate",
        "results/final_rigging",
        "results/rigging",
        "temp_input"
    ]
    for folder in folders:
        os.makedirs(folder, exist_ok=True)

    # 3. SETUP INPUT
    input_path = "temp_input/model.glb"
    shutil.copy(input_model.name, input_path)

    # 4. RUN THE RIGGING
    try:
        # We run the bash script you uploaded
        subprocess.run(["bash", "demo_rigging.sh"], check=True)
        
        # Check if the file was actually made
        output_path = "results/rigging/model_rigged.glb"
        if os.path.exists(output_path):
            return output_path
        else:
            return "Error: Rigging script finished but no file was generated. Check logs for 3D math errors."
            
    except Exception as e:
        return f"System Error: {str(e)}"

demo = gr.Interface(
    fn=run_rigging,
    inputs=gr.File(label="Upload GLB"),
    outputs=gr.File(label="Rigged Result"),
    api_name="rig"
)

demo.launch()