pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

Wrong dimension on gather

Open danielgordon10 opened this issue 4 months ago • 0 comments

https://github.com/facebookresearch/pytorch3d/blob/e17ed5cd50a1b43ed60ca4ff7a9a2e329c17c012/pytorch3d/renderer/mesh/textures.py#L1251

I noticed when running a render with multiple textures and faces_per_pixel > 1 that I was getting the result. I traced the issue to this line. pix_to_face has shape (N, image_size, image_size, faces_per_pixel) you can check your docs to confirm this. However the view call here orders it to (N, faces_per_pixel, image_size, image_size) which ends up mis-indexing lower down.

One obvious way to fix this is to change .view to .view(N, H_out, W_out, K).permute(0, 3, 1, 2). I have tested this and confirmed it gives appropriate results.

danielgordon10 avatar Oct 15 '24 21:10 danielgordon10