Skip to content

Commit fc156b5

Browse files
nikhilaravifacebook-github-bot
authored andcommitted
(bug) Fix exception when creating a TextureAtlas
Summary: Fixes GitHub issue #751. The vectorized implementation of bilinear interpolation didn't properly handle the edge cases in the same way as the `grid_sample` method in PyTorch. Reviewed By: bottler Differential Revision: D30684208 fbshipit-source-id: edf241ecbd72d46b94ad340a4e601e26c83db88e
1 parent 835e662 commit fc156b5

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

pytorch3d/io/mtl_io.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def make_material_atlas(
299299

300300
# bi-linearly interpolate the textures from the images
301301
# using the uv coordinates given by uv_pos.
302-
textures = _bilinear_interpolation_vectorized(image, uv_pos)
302+
textures = _bilinear_interpolation_grid_sample(image, uv_pos)
303303

304304
return textures
305305

@@ -311,11 +311,14 @@ def _bilinear_interpolation_vectorized(
311311
Bi linearly interpolate the image using the uv positions in the flow-field
312312
grid (following the naming conventions for torch.nn.functional.grid_sample).
313313
314-
This implementation uses the same steps as in the SoftRas cuda kernel
315-
to make it easy to compare. This vectorized version requires less memory than
314+
This implementation uses the same steps as in the SoftRasterizer CUDA kernel
315+
for loading textures. We are keeping it for reference to make it easy to
316+
compare if required.
317+
318+
However it doesn't properly handle the out of bound values in the same way as
319+
the grid_sample function does with the padding_mode argument.
320+
This vectorized version requires less memory than
316321
_bilinear_interpolation_grid_sample but is slightly slower.
317-
If speed is an issue and the number of faces in the mesh and texture image sizes
318-
are small, consider using _bilinear_interpolation_grid_sample instead.
319322
320323
Args:
321324
image: FloatTensor of shape (H, W, D) a single image/input tensor with D
-22 Bytes
Loading

0 commit comments

Comments
 (0)