Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|