Skip to content

Commit

Permalink
mesh_utils: add verbose;
Browse files Browse the repository at this point in the history
  • Loading branch information
ashawkey committed Jun 19, 2024
1 parent 20cadd9 commit 586a010
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions kiui/gridencoder/src/gridencoder.cu
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ void grid_encode_forward_cuda(const float *inputs, const scalar_t *embeddings, c
case 3: kernel_grid_wrapper<scalar_t, 3>(inputs, embeddings, offsets, outputs, B, C, L, max_level, S, H, dy_dx, gridtype, align_corners, interp); break;
case 4: kernel_grid_wrapper<scalar_t, 4>(inputs, embeddings, offsets, outputs, B, C, L, max_level, S, H, dy_dx, gridtype, align_corners, interp); break;
case 5: kernel_grid_wrapper<scalar_t, 5>(inputs, embeddings, offsets, outputs, B, C, L, max_level, S, H, dy_dx, gridtype, align_corners, interp); break;
default: throw std::runtime_error{"GridEncoding: C must be 1, 2, 4, or 8."};
default: throw std::runtime_error{"GridEncoding: D must be 2, 3, 4, or 5."};
}
}

Expand Down Expand Up @@ -630,7 +630,7 @@ void grad_total_variation_cuda(const scalar_t *inputs, const scalar_t *embedding
case 3: kernel_grad_tv_wrapper<scalar_t, 3>(inputs, embeddings, grad, offsets, weight, B, C, L, S, H, gridtype, align_corners); break;
case 4: kernel_grad_tv_wrapper<scalar_t, 4>(inputs, embeddings, grad, offsets, weight, B, C, L, S, H, gridtype, align_corners); break;
case 5: kernel_grad_tv_wrapper<scalar_t, 5>(inputs, embeddings, grad, offsets, weight, B, C, L, S, H, gridtype, align_corners); break;
default: throw std::runtime_error{"GridEncoding: C must be 1, 2, 4, or 8."};
default: throw std::runtime_error{"GridEncoding: D must be 2, 3, 4, or 5."};
}
}

Expand Down
11 changes: 8 additions & 3 deletions kiui/mesh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


def decimate_mesh(
verts, faces, target=5e4, backend="pymeshlab", remesh=False, optimalplacement=True
verts, faces, target=5e4, backend="pymeshlab", remesh=False, optimalplacement=True, verbose=True
):
""" perform mesh decimation.
Expand All @@ -41,6 +41,7 @@ def decimate_mesh(
backend (str, optional): algorithm backend, can be "pymeshlab" or "pyfqmr". Defaults to "pymeshlab".
remesh (bool, optional): whether to remesh after decimation. Defaults to False.
optimalplacement (bool, optional): For flat mesh, use False to prevent spikes. Defaults to True.
verbose (bool, optional): whether to print the decimation process. Defaults to True.
Returns:
Tuple[np.ndarray]: vertices and faces after decimation.
Expand Down Expand Up @@ -79,7 +80,8 @@ def decimate_mesh(
verts = m.vertex_matrix()
faces = m.face_matrix()

print(f"[INFO] mesh decimation: {_ori_vert_shape} --> {verts.shape}, {_ori_face_shape} --> {faces.shape}")
if verbose:
print(f"[INFO] mesh decimation: {_ori_vert_shape} --> {verts.shape}, {_ori_face_shape} --> {faces.shape}")

return verts, faces

Expand All @@ -94,6 +96,7 @@ def clean_mesh(
remesh=True,
remesh_size=0.01,
remesh_iters=3,
verbose=True,
):
""" perform mesh cleaning, including floater removal, non manifold repair, and remeshing.
Expand All @@ -107,6 +110,7 @@ def clean_mesh(
remesh (bool, optional): whether to perform a remeshing after all cleaning. Defaults to True.
remesh_size (float, optional): the targeted edge length for remeshing. Defaults to 0.01.
remesh_iters (int, optional): the iterations of remeshing. Defaults to 3.
verbose (bool, optional): whether to print the cleaning process. Defaults to True.
Returns:
Tuple[np.ndarray]: vertices and faces after decimation.
Expand Down Expand Up @@ -157,7 +161,8 @@ def clean_mesh(
verts = m.vertex_matrix()
faces = m.face_matrix()

print(f"[INFO] mesh cleaning: {_ori_vert_shape} --> {verts.shape}, {_ori_face_shape} --> {faces.shape}")
if verbose:
print(f"[INFO] mesh cleaning: {_ori_vert_shape} --> {verts.shape}, {_ori_face_shape} --> {faces.shape}")

return verts, faces

Expand Down

0 comments on commit 586a010

Please sign in to comment.