Spaces:
Sleeping
Sleeping
Update app.py
Browse filesnon cuda settings
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 |
-
#
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
#
|
| 35 |
-
mock_torchmcubes =
|
| 36 |
-
|
| 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 |
|