Spaces:
Running
on
Zero
Running
on
Zero
junbiao.chen
commited on
Commit
·
ceb457f
1
Parent(s):
ef4dc0e
trellis/representations/mesh/cube2mesh.py
CHANGED
@@ -2,8 +2,7 @@ import torch
|
|
2 |
from ...modules.sparse import SparseTensor
|
3 |
from easydict import EasyDict as edict
|
4 |
from .utils_cube import *
|
5 |
-
from .
|
6 |
-
|
7 |
|
8 |
class MeshExtractResult:
|
9 |
def __init__(self,
|
|
|
2 |
from ...modules.sparse import SparseTensor
|
3 |
from easydict import EasyDict as edict
|
4 |
from .utils_cube import *
|
5 |
+
from .flexicube import FlexiCubes
|
|
|
6 |
|
7 |
class MeshExtractResult:
|
8 |
def __init__(self,
|
trellis/representations/mesh/flexicube.py
CHANGED
@@ -48,6 +48,7 @@ class FlexiCubes:
|
|
48 |
|
49 |
def __call__(self, voxelgrid_vertices, scalar_field, cube_idx, resolution, qef_reg_scale=1e-3,
|
50 |
weight_scale=0.99, beta=None, alpha=None, gamma_f=None, voxelgrid_colors=None, training=False):
|
|
|
51 |
surf_cubes, occ_fx8 = self._identify_surf_cubes(scalar_field, cube_idx)
|
52 |
if surf_cubes.sum() == 0:
|
53 |
return (
|
@@ -356,4 +357,4 @@ class FlexiCubes:
|
|
356 |
vd = torch.cat([vd, vd_center])
|
357 |
faces = quad_vd_idx[:, self.quad_split_train].reshape(-1, 4, 2)
|
358 |
faces = torch.cat([faces, vd_center_idx.reshape(-1, 1, 1).repeat(1, 4, 1)], -1).reshape(-1, 3)
|
359 |
-
return vd, faces, s_edges, edge_indices, vd_color
|
|
|
48 |
|
49 |
def __call__(self, voxelgrid_vertices, scalar_field, cube_idx, resolution, qef_reg_scale=1e-3,
|
50 |
weight_scale=0.99, beta=None, alpha=None, gamma_f=None, voxelgrid_colors=None, training=False):
|
51 |
+
|
52 |
surf_cubes, occ_fx8 = self._identify_surf_cubes(scalar_field, cube_idx)
|
53 |
if surf_cubes.sum() == 0:
|
54 |
return (
|
|
|
357 |
vd = torch.cat([vd, vd_center])
|
358 |
faces = quad_vd_idx[:, self.quad_split_train].reshape(-1, 4, 2)
|
359 |
faces = torch.cat([faces, vd_center_idx.reshape(-1, 1, 1).repeat(1, 4, 1)], -1).reshape(-1, 3)
|
360 |
+
return vd, faces, s_edges, edge_indices, vd_color
|
trellis/representations/mesh/flexicubes/flexicubes.py
CHANGED
@@ -8,7 +8,6 @@
|
|
8 |
|
9 |
import torch
|
10 |
from .tables import *
|
11 |
-
from kaolin.utils.testing import check_tensor
|
12 |
|
13 |
__all__ = [
|
14 |
'FlexiCubes'
|
@@ -49,29 +48,6 @@ class FlexiCubes:
|
|
49 |
|
50 |
def __call__(self, voxelgrid_vertices, scalar_field, cube_idx, resolution, qef_reg_scale=1e-3,
|
51 |
weight_scale=0.99, beta=None, alpha=None, gamma_f=None, voxelgrid_colors=None, training=False):
|
52 |
-
assert torch.is_tensor(voxelgrid_vertices) and \
|
53 |
-
check_tensor(voxelgrid_vertices, (None, 3), throw=False), \
|
54 |
-
"'voxelgrid_vertices' should be a tensor of shape (num_vertices, 3)"
|
55 |
-
num_vertices = voxelgrid_vertices.shape[0]
|
56 |
-
assert torch.is_tensor(scalar_field) and \
|
57 |
-
check_tensor(scalar_field, (num_vertices,), throw=False), \
|
58 |
-
"'scalar_field' should be a tensor of shape (num_vertices,)"
|
59 |
-
assert torch.is_tensor(cube_idx) and \
|
60 |
-
check_tensor(cube_idx, (None, 8), throw=False), \
|
61 |
-
"'cube_idx' should be a tensor of shape (num_cubes, 8)"
|
62 |
-
num_cubes = cube_idx.shape[0]
|
63 |
-
assert beta is None or (
|
64 |
-
torch.is_tensor(beta) and
|
65 |
-
check_tensor(beta, (num_cubes, 12), throw=False)
|
66 |
-
), "'beta' should be a tensor of shape (num_cubes, 12)"
|
67 |
-
assert alpha is None or (
|
68 |
-
torch.is_tensor(alpha) and
|
69 |
-
check_tensor(alpha, (num_cubes, 8), throw=False)
|
70 |
-
), "'alpha' should be a tensor of shape (num_cubes, 8)"
|
71 |
-
assert gamma_f is None or (
|
72 |
-
torch.is_tensor(gamma_f) and
|
73 |
-
check_tensor(gamma_f, (num_cubes,), throw=False)
|
74 |
-
), "'gamma_f' should be a tensor of shape (num_cubes,)"
|
75 |
|
76 |
surf_cubes, occ_fx8 = self._identify_surf_cubes(scalar_field, cube_idx)
|
77 |
if surf_cubes.sum() == 0:
|
|
|
8 |
|
9 |
import torch
|
10 |
from .tables import *
|
|
|
11 |
|
12 |
__all__ = [
|
13 |
'FlexiCubes'
|
|
|
48 |
|
49 |
def __call__(self, voxelgrid_vertices, scalar_field, cube_idx, resolution, qef_reg_scale=1e-3,
|
50 |
weight_scale=0.99, beta=None, alpha=None, gamma_f=None, voxelgrid_colors=None, training=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
surf_cubes, occ_fx8 = self._identify_surf_cubes(scalar_field, cube_idx)
|
53 |
if surf_cubes.sum() == 0:
|