dashdoas commited on
Commit
2ee1ccf
·
verified ·
1 Parent(s): 95fe39f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -24
app.py CHANGED
@@ -1,47 +1,49 @@
1
  import gradio as gr
2
  import subprocess
3
  import os
4
- import shutil
 
 
 
 
5
 
6
  def rig_model(input_file):
7
- # Verify the official script exists
8
- if not os.path.exists("demo_rigging.sh"):
9
- return None, "Error: demo_rigging.sh not found in root. Clone failed."
 
 
10
 
11
- # Puppeteer outputs to this specific folder
12
  output_dir = "results/final_rigging"
13
- if os.path.exists(output_dir):
14
- shutil.rmtree(output_dir)
15
- os.makedirs(output_dir, exist_ok=True)
16
-
17
  try:
18
- # Run the bash command exactly as described in the GitHub
19
- # We pass the input file path as the first argument
20
  result = subprocess.run(
21
- ["bash", "demo_rigging.sh", input_file.name],
22
  capture_output=True,
23
  text=True
24
  )
25
 
26
- # Search for the generated GLB in the output directory
27
- generated_files = [f for f in os.listdir(output_dir) if f.endswith('.glb')]
28
-
29
- if generated_files:
30
- return os.path.join(output_dir, generated_files[0]), "Rigging Complete!"
31
  else:
32
- return None, f"Script ran but no GLB was found in {output_dir}.\n\nLog:\n{result.stderr}"
33
 
34
  except Exception as e:
35
  return None, f"System Error: {str(e)}"
36
 
37
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
38
- gr.Markdown("# 🎭 Puppeteer Auto-Rigging (Seed3D Official Setup)")
 
39
 
40
- input_file = gr.File(label="Upload Static GLB", file_types=[".glb"])
41
- run_btn = gr.Button("Start Rigging", variant="primary")
 
42
 
43
- out_file = gr.File(label="Rigged GLB Output")
44
- out_logs = gr.Textbox(label="Console Output", lines=10)
45
 
46
  run_btn.click(fn=rig_model, inputs=[input_file], outputs=[out_file, out_logs])
47
 
 
1
  import gradio as gr
2
  import subprocess
3
  import os
4
+
5
+ def check_files():
6
+ # Let's see exactly what we have
7
+ files = os.listdir('.')
8
+ return f"Files found in root: {files}"
9
 
10
  def rig_model(input_file):
11
+ # Absolute path check
12
+ script = os.path.abspath("demo_rigging.sh")
13
+
14
+ if not os.path.exists(script):
15
+ return None, f"Error: demo_rigging.sh NOT found. Root contains: {os.listdir('.')}"
16
 
 
17
  output_dir = "results/final_rigging"
18
+
 
 
 
19
  try:
20
+ # Run the official bash command
 
21
  result = subprocess.run(
22
+ ["bash", script, input_file.name],
23
  capture_output=True,
24
  text=True
25
  )
26
 
27
+ # Check for output
28
+ if os.path.exists(output_dir) and os.listdir(output_dir):
29
+ out_file = [f for f in os.listdir(output_dir) if f.endswith('.glb')][0]
30
+ return os.path.join(output_dir, out_file), "Success!"
 
31
  else:
32
+ return None, f"Failed. Bash Log:\n{result.stderr}\n{result.stdout}"
33
 
34
  except Exception as e:
35
  return None, f"System Error: {str(e)}"
36
 
37
+ with gr.Blocks() as demo:
38
+ gr.Markdown("# 🎭 Puppeteer Official Bash Setup")
39
+ gr.Markdown(check_files()) # This will show the file list at the top
40
 
41
+ with gr.Row():
42
+ input_file = gr.File(label="Upload GLB")
43
+ run_btn = gr.Button("Start Rigging", variant="primary")
44
 
45
+ out_file = gr.File(label="Rigged Result")
46
+ out_logs = gr.Textbox(label="Logs", lines=10)
47
 
48
  run_btn.click(fn=rig_model, inputs=[input_file], outputs=[out_file, out_logs])
49