Reverb commited on
Commit
eb018ed
·
1 Parent(s): 75e8e33

Fix: replace PyPI nvdiffrast (doesn't exist) with Jeff Xiang's prebuilt wheel

Browse files

nvdiffrast is not published on PyPI — pip found zero matching distributions.
Use the prebuilt cp310 wheel from JeffreyXiang/Storages instead.

Also add try/except guards at the top of every @spaces.GPU baking function
so that if the wheel fails to load at runtime (e.g. ABI mismatch with
torch 2.8+) the Space still boots and the baking steps return a clear
error message rather than crashing the process.

requirements.txt CHANGED
@@ -38,7 +38,10 @@ xatlas
38
  scipy # normal map dilation
39
 
40
  # ===== Milestone 5: Stage 2F Normal Baking =====
41
- nvdiffrast # PyPI version — compiles against installed CUDA at runtime
 
 
 
42
 
43
  coacd==1.0.4 # Milestone 8 collision
44
 
 
38
  scipy # normal map dilation
39
 
40
  # ===== Milestone 5: Stage 2F Normal Baking =====
41
+ # nvdiffrast is not on PyPI — use Jeff Xiang's prebuilt wheel.
42
+ # If this fails ABI checks at import time the baking functions
43
+ # degrade gracefully (they catch ImportError internally).
44
+ https://github.com/JeffreyXiang/Storages/releases/download/Space_Wheels_251210/nvdiffrast-0.4.0-cp310-cp310-linux_x86_64.whl
45
 
46
  coacd==1.0.4 # Milestone 8 collision
47
 
src/stages/stage2_bake_albedo.py CHANGED
@@ -56,9 +56,13 @@ def bake_albedo(
56
  Bake vertex-colour albedo from the high-poly to the low-poly UV atlas.
57
  Falls back to a neutral grey if the high-poly has no vertex colours.
58
  """
 
 
 
 
 
59
  import torch
60
  import trimesh
61
- import nvdiffrast.torch as dr
62
  from PIL import Image
63
 
64
  device = torch.device("cuda")
@@ -129,9 +133,13 @@ def bake_material(
129
  Bake metallic and roughness maps from high-poly vertex attributes.
130
  Returns (metallic_path, roughness_path, message).
131
  """
 
 
 
 
 
132
  import torch
133
  import trimesh
134
- import nvdiffrast.torch as dr
135
  from PIL import Image
136
 
137
  device = torch.device("cuda")
 
56
  Bake vertex-colour albedo from the high-poly to the low-poly UV atlas.
57
  Falls back to a neutral grey if the high-poly has no vertex colours.
58
  """
59
+ try:
60
+ import nvdiffrast.torch as dr
61
+ except Exception as e:
62
+ return None, f"⚠️ nvdiffrast unavailable: {e}"
63
+
64
  import torch
65
  import trimesh
 
66
  from PIL import Image
67
 
68
  device = torch.device("cuda")
 
133
  Bake metallic and roughness maps from high-poly vertex attributes.
134
  Returns (metallic_path, roughness_path, message).
135
  """
136
+ try:
137
+ import nvdiffrast.torch as dr
138
+ except Exception as e:
139
+ return None, None, f"⚠️ nvdiffrast unavailable: {e}"
140
+
141
  import torch
142
  import trimesh
 
143
  from PIL import Image
144
 
145
  device = torch.device("cuda")
src/stages/stage2_bake_ao.py CHANGED
@@ -67,9 +67,13 @@ def bake_ao(
67
  quality: str = "Standard", # "Fast" | "Standard" | "High"
68
  ) -> tuple[Path, str]:
69
  """Bake AO by hemisphere ray casting on the CPU (trimesh RayMesh intersector)."""
 
 
 
 
 
70
  import torch
71
  import trimesh
72
- import nvdiffrast.torch as dr
73
  from PIL import Image
74
 
75
  n_rays_map = {"Fast": 16, "Standard": 64, "High": 256}
 
67
  quality: str = "Standard", # "Fast" | "Standard" | "High"
68
  ) -> tuple[Path, str]:
69
  """Bake AO by hemisphere ray casting on the CPU (trimesh RayMesh intersector)."""
70
+ try:
71
+ import nvdiffrast.torch as dr
72
+ except Exception as e:
73
+ return None, f"⚠️ nvdiffrast unavailable: {e}"
74
+
75
  import torch
76
  import trimesh
 
77
  from PIL import Image
78
 
79
  n_rays_map = {"Fast": 16, "Standard": 64, "High": 256}
src/stages/stage2_bake_normal.py CHANGED
@@ -84,9 +84,13 @@ def bake_normal_map(
84
  dx_format: bool = True,
85
  ) -> tuple[Path, Path, str]:
86
  """Bake tangent-space normal maps. Returns (gl_path, dx_path, message)."""
 
 
 
 
 
87
  import torch
88
  import trimesh
89
- import nvdiffrast.torch as dr
90
  from PIL import Image
91
 
92
  device = torch.device("cuda")
 
84
  dx_format: bool = True,
85
  ) -> tuple[Path, Path, str]:
86
  """Bake tangent-space normal maps. Returns (gl_path, dx_path, message)."""
87
+ try:
88
+ import nvdiffrast.torch as dr
89
+ except Exception as e:
90
+ return None, None, f"⚠️ nvdiffrast unavailable: {e}"
91
+
92
  import torch
93
  import trimesh
 
94
  from PIL import Image
95
 
96
  device = torch.device("cuda")