prithivMLmods commited on
Commit
28b8328
·
verified ·
1 Parent(s): 3622963

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -3
app.py CHANGED
@@ -16,6 +16,29 @@ from gradio.themes.utils import colors, fonts, sizes
16
  import rerun as rr
17
  from gradio_rerun import Rerun
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  # --- Theme Configuration ---
20
  colors.orange_red = colors.Color(
21
  name="orange_red",
@@ -309,7 +332,7 @@ def generate_3d(
309
 
310
  run_id = str(uuid.uuid4())
311
 
312
- # Robustly handle different Rerun SDK versions for recording creation
313
  rec = None
314
  if hasattr(rr, "new_recording"):
315
  rec = rr.new_recording(application_id="TRELLIS-3D-Viewer", recording_id=run_id)
@@ -319,8 +342,7 @@ def generate_3d(
319
  rr.init("TRELLIS-3D-Viewer", recording_id=run_id, spawn=False)
320
  rec = rr
321
 
322
- # Log the GLB asset to Rerun
323
- # We use 'path' here which is compatible with most versions and handles reading the file.
324
  rec.log("generated_model", rr.Asset3D(path=glb_path), static=True)
325
 
326
  # Also log the input image for context
 
16
  import rerun as rr
17
  from gradio_rerun import Rerun
18
 
19
+ # --- Monkey Patch for cumesh to fix CUDA Error 9 ---
20
+ # This prevents the app from crashing if fill_holes fails due to mesh density
21
+ try:
22
+ import cumesh
23
+ # Save the original method just in case
24
+ if hasattr(cumesh, "Mesh"):
25
+ _original_fill_holes = cumesh.Mesh.fill_holes
26
+
27
+ def safe_fill_holes(self, *args, **kwargs):
28
+ try:
29
+ return _original_fill_holes(self, *args, **kwargs)
30
+ except RuntimeError as e:
31
+ print(f"Warning: cumesh.fill_holes failed (CUDA error skipped): {e}")
32
+ # We simply return None or pass, effectively skipping the step
33
+ return None
34
+
35
+ cumesh.Mesh.fill_holes = safe_fill_holes
36
+ print("Successfully monkey-patched cumesh.Mesh.fill_holes to handle CUDA errors.")
37
+ except ImportError:
38
+ print("Warning: cumesh not found, skipping monkey patch.")
39
+ except Exception as e:
40
+ print(f"Warning: Failed to monkey-patch cumesh: {e}")
41
+
42
  # --- Theme Configuration ---
43
  colors.orange_red = colors.Color(
44
  name="orange_red",
 
332
 
333
  run_id = str(uuid.uuid4())
334
 
335
+ # Robustly handle different Rerun SDK versions
336
  rec = None
337
  if hasattr(rr, "new_recording"):
338
  rec = rr.new_recording(application_id="TRELLIS-3D-Viewer", recording_id=run_id)
 
342
  rr.init("TRELLIS-3D-Viewer", recording_id=run_id, spawn=False)
343
  rec = rr
344
 
345
+ # Log the GLB asset using path (most robust way)
 
346
  rec.log("generated_model", rr.Asset3D(path=glb_path), static=True)
347
 
348
  # Also log the input image for context