Spaces:
Paused
Paused
Fix HF spaces
Browse files- sf3d/system.py +8 -10
sf3d/system.py
CHANGED
@@ -29,8 +29,6 @@ from sf3d.models.utils import (
|
|
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,7 +134,6 @@ class SF3D(BaseModule):
|
|
136 |
),
|
137 |
)
|
138 |
|
139 |
-
self.baker = TextureBaker()
|
140 |
self.image_processor = ImageProcessor()
|
141 |
|
142 |
def triplane_to_meshes(
|
@@ -284,6 +281,9 @@ class SF3D(BaseModule):
|
|
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,12 +314,10 @@ class SF3D(BaseModule):
|
|
314 |
mesh.unwrap_uv()
|
315 |
|
316 |
# Build textures
|
317 |
-
rast =
|
318 |
-
|
319 |
-
)
|
320 |
-
bake_mask = self.baker.get_mask(rast)
|
321 |
|
322 |
-
pos_bake =
|
323 |
mesh.v_pos,
|
324 |
rast,
|
325 |
mesh.t_pos_idx,
|
@@ -332,7 +330,7 @@ class SF3D(BaseModule):
|
|
332 |
tri_query, exclude=["density", "vertex_offset"]
|
333 |
)
|
334 |
|
335 |
-
nrm =
|
336 |
mesh.v_nrm,
|
337 |
rast,
|
338 |
mesh.t_pos_idx,
|
@@ -373,7 +371,7 @@ class SF3D(BaseModule):
|
|
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 =
|
377 |
mesh.v_tng,
|
378 |
rast,
|
379 |
mesh.t_pos_idx,
|
|
|
29 |
)
|
30 |
from sf3d.utils import create_intrinsic_from_fov_deg, default_cond_c2w
|
31 |
|
|
|
|
|
32 |
|
33 |
class SF3D(BaseModule):
|
34 |
@dataclass
|
|
|
134 |
),
|
135 |
)
|
136 |
|
|
|
137 |
self.image_processor = ImageProcessor()
|
138 |
|
139 |
def triplane_to_meshes(
|
|
|
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 |
mesh.unwrap_uv()
|
315 |
|
316 |
# Build textures
|
317 |
+
rast = baker.rasterize(mesh.v_tex, mesh.t_pos_idx, bake_resolution)
|
318 |
+
bake_mask = baker.get_mask(rast)
|
|
|
|
|
319 |
|
320 |
+
pos_bake = baker.interpolate(
|
321 |
mesh.v_pos,
|
322 |
rast,
|
323 |
mesh.t_pos_idx,
|
|
|
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 |
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,
|