Spaces:
Runtime error
Runtime error
Upload gradio_app.py
Browse files- gradio_app.py +7 -4
gradio_app.py
CHANGED
@@ -8,7 +8,7 @@ from PIL import Image
|
|
8 |
import gradio as gr
|
9 |
import trimesh
|
10 |
from transparent_background import Remover
|
11 |
-
|
12 |
import subprocess
|
13 |
|
14 |
def install_cuda_toolkit():
|
@@ -41,6 +41,8 @@ COND_HEIGHT = 512
|
|
41 |
COND_DISTANCE = 2.2
|
42 |
COND_FOVY = 0.591627
|
43 |
BACKGROUND_COLOR = [0.5, 0.5, 0.5]
|
|
|
|
|
44 |
|
45 |
# Initialize models
|
46 |
device = spar3d_utils.get_device()
|
@@ -208,8 +210,9 @@ def generate_and_process_3d(image: Image.Image) -> tuple[str | None, Image.Image
|
|
208 |
trimesh_mesh = trimesh_mesh[0]
|
209 |
|
210 |
# Export to GLB
|
211 |
-
temp_dir = tempfile.mkdtemp()
|
212 |
-
output_path = os.path.join(temp_dir, 'output.glb')
|
|
|
213 |
|
214 |
trimesh_mesh.export(output_path, file_type="glb", include_normals=True)
|
215 |
|
@@ -245,4 +248,4 @@ with gr.Blocks() as demo:
|
|
245 |
)
|
246 |
|
247 |
if __name__ == "__main__":
|
248 |
-
demo.queue().launch()
|
|
|
8 |
import gradio as gr
|
9 |
import trimesh
|
10 |
from transparent_background import Remover
|
11 |
+
from pathlib import Path
|
12 |
import subprocess
|
13 |
|
14 |
def install_cuda_toolkit():
|
|
|
41 |
COND_DISTANCE = 2.2
|
42 |
COND_FOVY = 0.591627
|
43 |
BACKGROUND_COLOR = [0.5, 0.5, 0.5]
|
44 |
+
OUTPUT_DIR = "output"
|
45 |
+
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
46 |
|
47 |
# Initialize models
|
48 |
device = spar3d_utils.get_device()
|
|
|
210 |
trimesh_mesh = trimesh_mesh[0]
|
211 |
|
212 |
# Export to GLB
|
213 |
+
#temp_dir = tempfile.mkdtemp()
|
214 |
+
#output_path = os.path.join(temp_dir, 'output.glb')
|
215 |
+
output_path = os.path.join(OUTPUT_DIR, 'output.glb')
|
216 |
|
217 |
trimesh_mesh.export(output_path, file_type="glb", include_normals=True)
|
218 |
|
|
|
248 |
)
|
249 |
|
250 |
if __name__ == "__main__":
|
251 |
+
demo.queue().launch(ssr_mode=False, allowed_paths=[Path(OUTPUT_DIR).resolve()])
|