Edoruin commited on
Commit
f4e3326
verified
1 Parent(s): d9b63d0

Update app.py

Browse files

non cuda settings

Files changed (1) hide show
  1. app.py +16 -9
app.py CHANGED
@@ -22,20 +22,27 @@ 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
 
 
22
  import sys
23
  import types
24
  import torch
 
25
 
26
+ # 1. try import mcubes
27
+ try:
28
+ import mcubes
29
+ except ImportError:
30
+ print("Error: PyMCubes no est谩 en requirements.txt")
31
+
32
+ # 2.parched mock
33
+ # false library for run
34
+ mock_torchmcubes = types.ModuleType("torchmcubes")
35
+
36
+ def marching_cubes_cpu(vertices, threshold):
37
+ # turning torch to numpy
38
  v, f = mcubes.marching_cubes(vertices.detach().cpu().numpy(), threshold)
39
  return torch.from_numpy(v.astype("float32")), torch.from_numpy(f.astype("int64"))
40
 
41
+ # send to function the false library
42
+ mock_torchmcubes.marching_cubes = marching_cubes_cpu
43
+ # register for TRIPOSD found the false module
44
  sys.modules["torchmcubes"] = mock_torchmcubes
45
+
46
 
47
 
48