Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the position map of the vertexs? [20481 3] unwarp to the uv [1024 1024 3]? #76

Open
Luh1124 opened this issue Jan 19, 2024 · 2 comments

Comments

@Luh1124
Copy link

Luh1124 commented Jan 19, 2024

No description provided.

@Luh1124 Luh1124 changed the title How to get the position map of How to get the position map of the vertexs? [20481 3] unwarp to the uv [1024 1024 3]? Jan 19, 2024
@Luh1124
Copy link
Author

Luh1124 commented Jan 19, 2024

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?

@Luh1124
Copy link
Author

Luh1124 commented Jan 19, 2024

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." ):
image

but when I resample the vertex:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant