Spaces:
Running on Zero
Running on Zero
Fix nvdiffrast ABI mismatch + pymeshfix TrackedArray crash
Browse files- Replace Jeff Xiang's prebuilt nvdiffrast wheel (built against PyTorch
~2.5.x) with a source build from git so it compiles against torch 2.8.0
- Add packages.txt with ninja-build and OpenGL headers needed for compilation
- Fix pymeshfix load_array crash: cast trimesh TrackedArray to plain
np.ndarray with correct dtypes (float64 vertices, int32 faces)
- packages.txt +6 -0
- requirements.txt +5 -4
- src/stages/stage2_repair.py +6 -1
packages.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# System packages installed by HF Spaces before pip install runs.
|
| 2 |
+
# Required to build nvdiffrast from source against torch 2.8.0.
|
| 3 |
+
ninja-build
|
| 4 |
+
libgl1-mesa-glx
|
| 5 |
+
libgles2-mesa-dev
|
| 6 |
+
libglfw3-dev
|
requirements.txt
CHANGED
|
@@ -50,10 +50,11 @@ xatlas
|
|
| 50 |
scipy # normal map dilation
|
| 51 |
|
| 52 |
# ===== Milestone 5: Stage 2F Normal Baking =====
|
| 53 |
-
# nvdiffrast
|
| 54 |
-
#
|
| 55 |
-
#
|
| 56 |
-
|
|
|
|
| 57 |
|
| 58 |
coacd==1.0.4 # Milestone 8 collision
|
| 59 |
|
|
|
|
| 50 |
scipy # normal map dilation
|
| 51 |
|
| 52 |
# ===== Milestone 5: Stage 2F Normal Baking =====
|
| 53 |
+
# Build nvdiffrast from source against the installed torch version.
|
| 54 |
+
# Jeff Xiang's prebuilt wheel (Space_Wheels_251210) was compiled against
|
| 55 |
+
# PyTorch ~2.5.x and fails with an ABI mismatch on torch 2.8.0.
|
| 56 |
+
# Source build via git requires ninja-build + OpenGL headers (packages.txt).
|
| 57 |
+
git+https://github.com/NVlabs/nvdiffrast.git
|
| 58 |
|
| 59 |
coacd==1.0.4 # Milestone 8 collision
|
| 60 |
|
src/stages/stage2_repair.py
CHANGED
|
@@ -3,6 +3,8 @@ from __future__ import annotations
|
|
| 3 |
|
| 4 |
from pathlib import Path
|
| 5 |
|
|
|
|
|
|
|
| 6 |
from src import workspace
|
| 7 |
from src.workspace import CURRENT
|
| 8 |
|
|
@@ -13,7 +15,10 @@ def repair_mesh(input_glb: Path) -> tuple[Path, str]:
|
|
| 13 |
import pymeshfix
|
| 14 |
|
| 15 |
mesh = trimesh.load(str(input_glb), force="mesh")
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
tin = pymeshfix.PyTMesh() # verbose kwarg removed in pymeshfix ≥ 0.17
|
| 19 |
tin.load_array(v, f)
|
|
|
|
| 3 |
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
from src import workspace
|
| 9 |
from src.workspace import CURRENT
|
| 10 |
|
|
|
|
| 15 |
import pymeshfix
|
| 16 |
|
| 17 |
mesh = trimesh.load(str(input_glb), force="mesh")
|
| 18 |
+
# pymeshfix.load_array requires plain ndarray (not TrackedArray subclass),
|
| 19 |
+
# float64 vertices, int32 faces, C-contiguous.
|
| 20 |
+
v = np.ascontiguousarray(mesh.vertices, dtype=np.float64)
|
| 21 |
+
f = np.ascontiguousarray(mesh.faces, dtype=np.int32)
|
| 22 |
|
| 23 |
tin = pymeshfix.PyTMesh() # verbose kwarg removed in pymeshfix ≥ 0.17
|
| 24 |
tin.load_array(v, f)
|