Open Luh1124 opened 10 months ago
my code and results:
def visualize_3dmmver_as_uv(self):
ver_vertex = self.pred_vertex[0, :, :].detach().cpu().numpy()
unwrap_uv_idx_v_idx = self.facemodel.unwrap_uv_idx_v_idx.detach().cpu().numpy()
unwrap_uv_idx_bw = self.facemodel.unwrap_uv_idx_bw.detach().cpu().numpy()
vertex_uv = unwrap_vertex_to_uv(ver_vertex, unwrap_uv_idx_v_idx, unwrap_uv_idx_bw)
return vertex_uv
def inverse_vertex_from_vertex_uv(self, vertex_uv):
vtx_vt = (self.facemodel.vtx_vt / 512) * 2 - 1 # [-1, 1] [20481 2]
vertex_uv = torch.from_numpy(vertex_uv).unsqueeze(0).to(self.device) # [1, H, W, 2]
inverse_vertex = F.grid_sample(vertex_uv.permute(0, 3, 1, 2), vtx_vt.unsqueeze(0).unsqueeze(0), mode='bilinear') # [1, 3, 1, 20481]
inverse_vertex = inverse_vertex.permute(0, 2, 3, 1).squeeze(0).detach().cpu().numpy()
return inverse_vertex # [1, 20481, 3]
simple visualization("Ignore numerical overflow." ):
but when I resample the vertex:
I'm trying to use the function “unwrap_vertex_to_uv” to unwrap the spatial position coordinates of the vertices to UV, but I'm encountering issues with bilinear interpolation and resampling based on the vertex UV coordinates. Can you give me a hint on how to achieve the correct results for the position map unwrapping?