Spaces:
Build error
Build error
Vo Minh Vu
commited on
Commit
·
857d4d1
1
Parent(s):
6dd317e
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import io
|
| 2 |
import os
|
| 3 |
import shlex
|
|
@@ -21,14 +35,6 @@ from tsr.utils import remove_background, resize_foreground, to_gradio_3d_orienta
|
|
| 21 |
# ------------------------------------------------------------
|
| 22 |
# 1. Model & utils initialization (runs at startup)
|
| 23 |
# ------------------------------------------------------------
|
| 24 |
-
# Install any local wheels (if needed)
|
| 25 |
-
subprocess.run(
|
| 26 |
-
shlex.split(
|
| 27 |
-
"pip install wheel/torchmcubes-0.1.0-cp310-cp310-linux_x86_64.whl"
|
| 28 |
-
),
|
| 29 |
-
check=False,
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
# device
|
| 33 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
| 34 |
|
|
|
|
| 1 |
+
import sys, subprocess
|
| 2 |
+
|
| 3 |
+
# 1) Try importing; if it fails, install your wheel
|
| 4 |
+
try:
|
| 5 |
+
import torchmcubes
|
| 6 |
+
except ImportError:
|
| 7 |
+
subprocess.check_call([
|
| 8 |
+
sys.executable, "-m", "pip", "install",
|
| 9 |
+
"./wheels/torchmcubes-0.1.0-cp310-cp310-linux_x86_64.whl"
|
| 10 |
+
])
|
| 11 |
+
# now it's installed, so re-import
|
| 12 |
+
import torchmcubes
|
| 13 |
+
|
| 14 |
+
# 2) Now safe to import the rest of your app
|
| 15 |
import io
|
| 16 |
import os
|
| 17 |
import shlex
|
|
|
|
| 35 |
# ------------------------------------------------------------
|
| 36 |
# 1. Model & utils initialization (runs at startup)
|
| 37 |
# ------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
# device
|
| 39 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
| 40 |
|