Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions training/networks_get3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,26 @@ def extract_3d_shape(
else:
mesh_v, mesh_f, sdf, deformation, v_deformed, sdf_reg_loss = self.get_geometry_prediction(ws_geo)

# Step 1.5: fix the mesh
import pymesh
mesh_v_processed = []
mesh_f_processed = []

for v, f in zip(mesh_v, mesh_f):
mesh = pymesh.form_mesh(vertices=v.cpu().numpy(), faces=f.cpu().numpy())
mesh, info = pymesh.remove_isolated_vertices(mesh)
mesh, info = pymesh.remove_duplicated_vertices(mesh, 1e-3)
print(info)

tensor_vertices = torch.from_numpy(mesh.vertices).float().to(self.device)
tensor_faces = torch.from_numpy(mesh.faces).long().to(self.device)
mesh_v_processed.append(tensor_vertices)
mesh_f_processed.append(tensor_faces)

mesh_v = mesh_v_processed
mesh_f = mesh_f_processed


# Step 2: use x-atlas to get uv mapping for the mesh
from training.extract_texture_map import xatlas_uvmap
all_uvs = []
Expand Down