Spaces:
Paused
Paused
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -39,7 +39,7 @@ def _pip(*a):
|
|
| 39 |
|
| 40 |
print("=== Runtime installs ===")
|
| 41 |
_pip("open3d>=0.18.0")
|
| 42 |
-
_pip("utils3d")
|
| 43 |
_pip("iopath")
|
| 44 |
_pip("--no-deps", "sam2>=1.1.0")
|
| 45 |
_pip("--no-deps", "git+https://github.com/microsoft/MoGe.git@a8c37341bc0325ca99b9d57981cc3bb2bd3e255b")
|
|
@@ -50,8 +50,7 @@ for idx in ["https://docs.gsplat.studio/whl/pt210cu128",
|
|
| 50 |
if _pip("--no-deps", f"--extra-index-url={idx}", "gsplat"):
|
| 51 |
break
|
| 52 |
|
| 53 |
-
# DO NOT import CUDA-dependent packages here
|
| 54 |
-
# Importing gsplat/open3d at startup can init CUDA and break ZeroGPU.
|
| 55 |
|
| 56 |
# --- Clone sam-3d-objects ---
|
| 57 |
SAM3D_PATH = Path("/home/user/app/sam-3d-objects")
|
|
@@ -83,38 +82,27 @@ if hf_ckpt.exists() and not local_ckpt.exists():
|
|
| 83 |
local_ckpt.symlink_to(hf_ckpt)
|
| 84 |
CONFIG_PATH = str(local_ckpt / "pipeline.yaml")
|
| 85 |
print(f"Config exists: {Path(CONFIG_PATH).exists()}")
|
| 86 |
-
print("=== Startup complete
|
| 87 |
|
| 88 |
# --- Endpoints ---
|
| 89 |
|
| 90 |
@spaces.GPU(duration=60)
|
| 91 |
def diagnose():
|
| 92 |
-
"""Test GPU and modules in isolated manner."""
|
| 93 |
import torch
|
| 94 |
lines = [f"torch={torch.__version__}", f"cuda={torch.cuda.is_available()}"]
|
| 95 |
if torch.cuda.is_available():
|
| 96 |
lines.append(f"gpu={torch.cuda.get_device_name()}")
|
| 97 |
-
|
| 98 |
-
for mod in ["kaolin", "utils3d", "iopath", "pytorch3d"]:
|
| 99 |
try:
|
| 100 |
m = __import__(mod)
|
| 101 |
lines.append(f"{mod}: OK ({getattr(m, '__version__', '-')})")
|
| 102 |
except Exception as e:
|
| 103 |
lines.append(f"{mod}: FAIL - {e}")
|
| 104 |
-
# Test CUDA modules one at a time
|
| 105 |
-
for mod in ["open3d", "gsplat", "moge"]:
|
| 106 |
-
try:
|
| 107 |
-
m = __import__(mod)
|
| 108 |
-
lines.append(f"{mod}: OK ({getattr(m, '__version__', '-')})")
|
| 109 |
-
except Exception as e:
|
| 110 |
-
lines.append(f"{mod}: FAIL - {e}")
|
| 111 |
-
# sam2
|
| 112 |
try:
|
| 113 |
from sam2.automatic_mask_generator import SAM2AutomaticMaskGenerator
|
| 114 |
lines.append("sam2: OK")
|
| 115 |
except Exception as e:
|
| 116 |
lines.append(f"sam2: FAIL - {e}")
|
| 117 |
-
# SAM3D inference
|
| 118 |
try:
|
| 119 |
from inference import Inference
|
| 120 |
lines.append("SAM3D Inference: importable")
|
|
|
|
| 39 |
|
| 40 |
print("=== Runtime installs ===")
|
| 41 |
_pip("open3d>=0.18.0")
|
| 42 |
+
_pip("--no-deps", "utils3d") # --no-deps: skip jupyter dependency
|
| 43 |
_pip("iopath")
|
| 44 |
_pip("--no-deps", "sam2>=1.1.0")
|
| 45 |
_pip("--no-deps", "git+https://github.com/microsoft/MoGe.git@a8c37341bc0325ca99b9d57981cc3bb2bd3e255b")
|
|
|
|
| 50 |
if _pip("--no-deps", f"--extra-index-url={idx}", "gsplat"):
|
| 51 |
break
|
| 52 |
|
| 53 |
+
# DO NOT import CUDA-dependent packages here!
|
|
|
|
| 54 |
|
| 55 |
# --- Clone sam-3d-objects ---
|
| 56 |
SAM3D_PATH = Path("/home/user/app/sam-3d-objects")
|
|
|
|
| 82 |
local_ckpt.symlink_to(hf_ckpt)
|
| 83 |
CONFIG_PATH = str(local_ckpt / "pipeline.yaml")
|
| 84 |
print(f"Config exists: {Path(CONFIG_PATH).exists()}")
|
| 85 |
+
print("=== Startup complete ===")
|
| 86 |
|
| 87 |
# --- Endpoints ---
|
| 88 |
|
| 89 |
@spaces.GPU(duration=60)
|
| 90 |
def diagnose():
|
|
|
|
| 91 |
import torch
|
| 92 |
lines = [f"torch={torch.__version__}", f"cuda={torch.cuda.is_available()}"]
|
| 93 |
if torch.cuda.is_available():
|
| 94 |
lines.append(f"gpu={torch.cuda.get_device_name()}")
|
| 95 |
+
for mod in ["kaolin", "utils3d", "iopath", "pytorch3d", "open3d", "gsplat", "moge"]:
|
|
|
|
| 96 |
try:
|
| 97 |
m = __import__(mod)
|
| 98 |
lines.append(f"{mod}: OK ({getattr(m, '__version__', '-')})")
|
| 99 |
except Exception as e:
|
| 100 |
lines.append(f"{mod}: FAIL - {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
try:
|
| 102 |
from sam2.automatic_mask_generator import SAM2AutomaticMaskGenerator
|
| 103 |
lines.append("sam2: OK")
|
| 104 |
except Exception as e:
|
| 105 |
lines.append(f"sam2: FAIL - {e}")
|
|
|
|
| 106 |
try:
|
| 107 |
from inference import Inference
|
| 108 |
lines.append("SAM3D Inference: importable")
|