dashdoas commited on
Commit
0408c90
·
verified ·
1 Parent(s): 750813c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -19
app.py CHANGED
@@ -1,34 +1,53 @@
1
  import gradio as gr
2
- import subprocess
3
  import os
 
 
4
  import shutil
5
 
 
 
 
 
 
 
 
6
  def run_rigging(input_model):
7
- # 1. Create a clean work folder
8
- if os.path.exists("temp_input"):
9
- shutil.rmtree("temp_input")
10
- os.makedirs("temp_input", exist_ok=True)
11
-
12
- # 2. Save your uploaded file into the input folder
13
- input_path = os.path.join("temp_input", "model.glb")
 
 
 
 
 
 
 
14
  shutil.copy(input_model.name, input_path)
15
-
16
- # 3. Trigger the Seed3D rigging script
17
- # We use subprocess to run the .sh file you dragged into the repo
18
  try:
 
19
  subprocess.run(["bash", "demo_rigging.sh"], check=True)
20
- # Seed3D usually saves results in a 'results' folder
21
- output_path = "results/rigging/model_rigged.glb"
22
- return output_path
 
 
 
 
 
23
  except Exception as e:
24
- return f"Error during rigging: {str(e)}"
25
 
26
- # This creates the "API Door" for your AI Studio app
27
  demo = gr.Interface(
28
  fn=run_rigging,
29
- inputs=gr.File(label="Upload Model"),
30
- outputs=gr.File(label="Download Rigged Model"),
31
- api_name="rig"
32
  )
33
 
34
  demo.launch()
 
1
  import gradio as gr
 
2
  import os
3
+ import subprocess
4
+ import sys
5
  import shutil
6
 
7
+ # 1. FORCE PYTHON TO SEE YOUR UPLOADED FOLDERS
8
+ # This fixes the 'No module named third_partys' error
9
+ current_dir = os.path.dirname(os.path.abspath(__file__))
10
+ sys.path.append(current_dir)
11
+ sys.path.append(os.path.join(current_dir, "skeleton"))
12
+ sys.path.append(os.path.join(current_dir, "skinning"))
13
+
14
  def run_rigging(input_model):
15
+ # 2. MANUALLY CREATE MISSING FOLDERS
16
+ # This fixes the 'No such file or directory' errors in the .sh script
17
+ folders = [
18
+ "results/skel_results",
19
+ "results/skin_results/generate",
20
+ "results/final_rigging",
21
+ "results/rigging",
22
+ "temp_input"
23
+ ]
24
+ for folder in folders:
25
+ os.makedirs(folder, exist_ok=True)
26
+
27
+ # 3. SETUP INPUT
28
+ input_path = "temp_input/model.glb"
29
  shutil.copy(input_model.name, input_path)
30
+
31
+ # 4. RUN THE RIGGING
 
32
  try:
33
+ # We run the bash script you uploaded
34
  subprocess.run(["bash", "demo_rigging.sh"], check=True)
35
+
36
+ # Check if the file was actually made
37
+ output_path = "results/rigging/model_rigged.glb"
38
+ if os.path.exists(output_path):
39
+ return output_path
40
+ else:
41
+ return "Error: Rigging script finished but no file was generated. Check logs for 3D math errors."
42
+
43
  except Exception as e:
44
+ return f"System Error: {str(e)}"
45
 
 
46
  demo = gr.Interface(
47
  fn=run_rigging,
48
+ inputs=gr.File(label="Upload GLB"),
49
+ outputs=gr.File(label="Rigged Result"),
50
+ api_name="rig"
51
  )
52
 
53
  demo.launch()