Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,16 @@ import spaces
|
|
11 |
# Path to the cloned UniRig repository directory within the Space
|
12 |
UNIRIG_REPO_DIR = os.path.join(os.path.dirname(__file__), "UniRig")
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
if not os.path.isdir(UNIRIG_REPO_DIR):
|
15 |
print(f"ERROR: UniRig repository not found at {UNIRIG_REPO_DIR}. Please clone it there.")
|
16 |
# Consider raising an error or displaying it in the UI if UniRig is critical for startup
|
@@ -52,7 +62,6 @@ def run_unirig_command(command_list, step_name):
|
|
52 |
process_env["PYTHONPATH"] = os.pathsep.join(filter(None, new_pythonpath_parts)) # filter(None,...) handles empty existing_pythonpath
|
53 |
print(f"Set PYTHONPATH for subprocess: {process_env['PYTHONPATH']}")
|
54 |
|
55 |
-
|
56 |
try:
|
57 |
# Execute the command from the UniRig directory (UNIRIG_REPO_DIR)
|
58 |
# This is crucial for the bash scripts to find their relative paths (e.g., to Python scripts)
|
@@ -78,7 +87,6 @@ def run_unirig_command(command_list, step_name):
|
|
78 |
print(f"An unexpected Python exception occurred in run_unirig_command for {step_name}: {e_general}")
|
79 |
raise gr.Error(f"Unexpected Python error during {step_name}: {str(e_general)[:500]}")
|
80 |
|
81 |
-
|
82 |
@spaces.GPU # Decorator for ZeroGPU
|
83 |
def rig_glb_mesh_multistep(input_glb_file_obj):
|
84 |
"""
|
@@ -161,7 +169,6 @@ def rig_glb_mesh_multistep(input_glb_file_obj):
|
|
161 |
print(f"Cleaned up temporary directory: {processing_temp_dir}")
|
162 |
raise gr.Error(f"An unexpected error occurred during processing: {str(e)[:500]}")
|
163 |
|
164 |
-
|
165 |
# --- Gradio Interface ---
|
166 |
theme = gr.themes.Soft(
|
167 |
primary_hue=gr.themes.colors.sky,
|
|
|
11 |
# Path to the cloned UniRig repository directory within the Space
|
12 |
UNIRIG_REPO_DIR = os.path.join(os.path.dirname(__file__), "UniRig")
|
13 |
|
14 |
+
# Path to the setup script
|
15 |
+
SETUP_SCRIPT = os.path.join(os.path.dirname(__file__), "setup_blender.sh")
|
16 |
+
|
17 |
+
# Check if Blender is installed
|
18 |
+
if not os.path.exists("/usr/local/bin/blender"):
|
19 |
+
print("Blender not found. Installing...")
|
20 |
+
subprocess.run(["bash", SETUP_SCRIPT], check=True)
|
21 |
+
else:
|
22 |
+
print("Blender is already installed.")
|
23 |
+
|
24 |
if not os.path.isdir(UNIRIG_REPO_DIR):
|
25 |
print(f"ERROR: UniRig repository not found at {UNIRIG_REPO_DIR}. Please clone it there.")
|
26 |
# Consider raising an error or displaying it in the UI if UniRig is critical for startup
|
|
|
62 |
process_env["PYTHONPATH"] = os.pathsep.join(filter(None, new_pythonpath_parts)) # filter(None,...) handles empty existing_pythonpath
|
63 |
print(f"Set PYTHONPATH for subprocess: {process_env['PYTHONPATH']}")
|
64 |
|
|
|
65 |
try:
|
66 |
# Execute the command from the UniRig directory (UNIRIG_REPO_DIR)
|
67 |
# This is crucial for the bash scripts to find their relative paths (e.g., to Python scripts)
|
|
|
87 |
print(f"An unexpected Python exception occurred in run_unirig_command for {step_name}: {e_general}")
|
88 |
raise gr.Error(f"Unexpected Python error during {step_name}: {str(e_general)[:500]}")
|
89 |
|
|
|
90 |
@spaces.GPU # Decorator for ZeroGPU
|
91 |
def rig_glb_mesh_multistep(input_glb_file_obj):
|
92 |
"""
|
|
|
169 |
print(f"Cleaned up temporary directory: {processing_temp_dir}")
|
170 |
raise gr.Error(f"An unexpected error occurred during processing: {str(e)[:500]}")
|
171 |
|
|
|
172 |
# --- Gradio Interface ---
|
173 |
theme = gr.themes.Soft(
|
174 |
primary_hue=gr.themes.colors.sky,
|