Edoruin commited on
Commit
9bbf979
verified
1 Parent(s): 2231d56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -19,12 +19,24 @@ from tsr.system import TSR
19
  from tsr.utils import remove_background, resize_foreground, to_gradio_3d_orientation
20
 
21
  from torchmcubes import marching_cubes
 
 
 
22
  import mcubes
23
 
24
- def marching_cubes(vertices, threshold):
25
- # Simula la funci贸n original usando la librer铆a de CPU
 
 
26
  v, f = mcubes.marching_cubes(vertices.detach().cpu().numpy(), threshold)
27
- return torch.from_numpy(v), torch.from_numpy(f)
 
 
 
 
 
 
 
28
 
29
 
30
 
 
19
  from tsr.utils import remove_background, resize_foreground, to_gradio_3d_orientation
20
 
21
  from torchmcubes import marching_cubes
22
+ import sys
23
+ import types
24
+ import torch
25
  import mcubes
26
 
27
+ # --- SIMULADOR DE TORCHMCUBES PARA CPU ---
28
+ # Esto enga帽a al c贸digo de TripoSR para que use PyMCubes en lugar de la versi贸n de GPU
29
+ def marching_cubes_proxy(vertices, threshold):
30
+ # Convertimos el tensor de torch a numpy para que mcubes lo procese en CPU
31
  v, f = mcubes.marching_cubes(vertices.detach().cpu().numpy(), threshold)
32
+ return torch.from_numpy(v.astype("float32")), torch.from_numpy(f.astype("int64"))
33
+
34
+ # Creamos un m贸dulo virtual llamado 'torchmcubes'
35
+ mock_torchmcubes = types.ModuleType("torchmcubes")
36
+ mock_torchmcubes.marching_cubes = marching_cubes_proxy
37
+ sys.modules["torchmcubes"] = mock_torchmcubes
38
+ # --------------------------------------------------------
39
+
40
 
41
 
42