Spaces:
Runtime error
Runtime error
Revert "Fix HF spaces"
Browse filesThis reverts commit 0c2b278dc4a9ddbfbaeac56affd8ca6c01cd22de.
- sf3d/system.py +10 -8
sf3d/system.py
CHANGED
@@ -29,6 +29,8 @@ from sf3d.models.utils import (
|
|
29 |
)
|
30 |
from sf3d.utils import create_intrinsic_from_fov_deg, default_cond_c2w
|
31 |
|
|
|
|
|
32 |
|
33 |
class SF3D(BaseModule):
|
34 |
@dataclass
|
@@ -134,6 +136,7 @@ class SF3D(BaseModule):
|
|
134 |
),
|
135 |
)
|
136 |
|
|
|
137 |
self.image_processor = ImageProcessor()
|
138 |
|
139 |
def triplane_to_meshes(
|
@@ -281,9 +284,6 @@ class SF3D(BaseModule):
|
|
281 |
bake_resolution: int,
|
282 |
estimate_illumination: bool = False,
|
283 |
) -> Tuple[List[trimesh.Trimesh], dict[str, Any]]:
|
284 |
-
from .texture_baker import TextureBaker
|
285 |
-
|
286 |
-
baker = TextureBaker()
|
287 |
batch["rgb_cond"] = self.image_processor(
|
288 |
batch["rgb_cond"], self.cfg.cond_image_size
|
289 |
)
|
@@ -314,10 +314,12 @@ class SF3D(BaseModule):
|
|
314 |
mesh.unwrap_uv()
|
315 |
|
316 |
# Build textures
|
317 |
-
rast = baker.rasterize(
|
318 |
-
|
|
|
|
|
319 |
|
320 |
-
pos_bake = baker.interpolate(
|
321 |
mesh.v_pos,
|
322 |
rast,
|
323 |
mesh.t_pos_idx,
|
@@ -330,7 +332,7 @@ class SF3D(BaseModule):
|
|
330 |
tri_query, exclude=["density", "vertex_offset"]
|
331 |
)
|
332 |
|
333 |
-
nrm = baker.interpolate(
|
334 |
mesh.v_nrm,
|
335 |
rast,
|
336 |
mesh.t_pos_idx,
|
@@ -371,7 +373,7 @@ class SF3D(BaseModule):
|
|
371 |
if k == "normal":
|
372 |
# Use un-normalized tangents here so that larger smaller tris
|
373 |
# Don't effect the tangents that much
|
374 |
-
tng = baker.interpolate(
|
375 |
mesh.v_tng,
|
376 |
rast,
|
377 |
mesh.t_pos_idx,
|
|
|
29 |
)
|
30 |
from sf3d.utils import create_intrinsic_from_fov_deg, default_cond_c2w
|
31 |
|
32 |
+
from .texture_baker import TextureBaker
|
33 |
+
|
34 |
|
35 |
class SF3D(BaseModule):
|
36 |
@dataclass
|
|
|
136 |
),
|
137 |
)
|
138 |
|
139 |
+
self.baker = TextureBaker()
|
140 |
self.image_processor = ImageProcessor()
|
141 |
|
142 |
def triplane_to_meshes(
|
|
|
284 |
bake_resolution: int,
|
285 |
estimate_illumination: bool = False,
|
286 |
) -> Tuple[List[trimesh.Trimesh], dict[str, Any]]:
|
|
|
|
|
|
|
287 |
batch["rgb_cond"] = self.image_processor(
|
288 |
batch["rgb_cond"], self.cfg.cond_image_size
|
289 |
)
|
|
|
314 |
mesh.unwrap_uv()
|
315 |
|
316 |
# Build textures
|
317 |
+
rast = self.baker.rasterize(
|
318 |
+
mesh.v_tex, mesh.t_pos_idx, bake_resolution
|
319 |
+
)
|
320 |
+
bake_mask = self.baker.get_mask(rast)
|
321 |
|
322 |
+
pos_bake = self.baker.interpolate(
|
323 |
mesh.v_pos,
|
324 |
rast,
|
325 |
mesh.t_pos_idx,
|
|
|
332 |
tri_query, exclude=["density", "vertex_offset"]
|
333 |
)
|
334 |
|
335 |
+
nrm = self.baker.interpolate(
|
336 |
mesh.v_nrm,
|
337 |
rast,
|
338 |
mesh.t_pos_idx,
|
|
|
373 |
if k == "normal":
|
374 |
# Use un-normalized tangents here so that larger smaller tris
|
375 |
# Don't effect the tangents that much
|
376 |
+
tng = self.baker.interpolate(
|
377 |
mesh.v_tng,
|
378 |
rast,
|
379 |
mesh.t_pos_idx,
|