Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,47 +1,49 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
import os
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def rig_model(input_file):
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
# Puppeteer outputs to this specific folder
|
| 12 |
output_dir = "results/final_rigging"
|
| 13 |
-
|
| 14 |
-
shutil.rmtree(output_dir)
|
| 15 |
-
os.makedirs(output_dir, exist_ok=True)
|
| 16 |
-
|
| 17 |
try:
|
| 18 |
-
# Run the bash command
|
| 19 |
-
# We pass the input file path as the first argument
|
| 20 |
result = subprocess.run(
|
| 21 |
-
["bash",
|
| 22 |
capture_output=True,
|
| 23 |
text=True
|
| 24 |
)
|
| 25 |
|
| 26 |
-
#
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
return os.path.join(output_dir, generated_files[0]), "Rigging Complete!"
|
| 31 |
else:
|
| 32 |
-
return None, f"
|
| 33 |
|
| 34 |
except Exception as e:
|
| 35 |
return None, f"System Error: {str(e)}"
|
| 36 |
|
| 37 |
-
with gr.Blocks(
|
| 38 |
-
gr.Markdown("# 🎭 Puppeteer
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
|
|
|
| 42 |
|
| 43 |
-
out_file = gr.File(label="Rigged
|
| 44 |
-
out_logs = gr.Textbox(label="
|
| 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 |
|