Commit fc156b50 authored by Nikhila Ravi's avatar Nikhila Ravi Committed by Facebook GitHub Bot
Browse files

(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
parent 835e662f
...@@ -299,7 +299,7 @@ def make_material_atlas( ...@@ -299,7 +299,7 @@ def make_material_atlas(
# bi-linearly interpolate the textures from the images # bi-linearly interpolate the textures from the images
# using the uv coordinates given by uv_pos. # using the uv coordinates given by uv_pos.
textures = _bilinear_interpolation_vectorized(image, uv_pos) textures = _bilinear_interpolation_grid_sample(image, uv_pos)
return textures return textures
...@@ -311,11 +311,14 @@ def _bilinear_interpolation_vectorized( ...@@ -311,11 +311,14 @@ def _bilinear_interpolation_vectorized(
Bi linearly interpolate the image using the uv positions in the flow-field Bi linearly interpolate the image using the uv positions in the flow-field
grid (following the naming conventions for torch.nn.functional.grid_sample). grid (following the naming conventions for torch.nn.functional.grid_sample).
This implementation uses the same steps as in the SoftRas cuda kernel This implementation uses the same steps as in the SoftRasterizer CUDA kernel
to make it easy to compare. This vectorized version requires less memory than for loading textures. We are keeping it for reference to make it easy to
compare if required.
However it doesn't properly handle the out of bound values in the same way as
the grid_sample function does with the padding_mode argument.
This vectorized version requires less memory than
_bilinear_interpolation_grid_sample but is slightly slower. _bilinear_interpolation_grid_sample but is slightly slower.
If speed is an issue and the number of faces in the mesh and texture image sizes
are small, consider using _bilinear_interpolation_grid_sample instead.
Args: Args:
image: FloatTensor of shape (H, W, D) a single image/input tensor with D image: FloatTensor of shape (H, W, D) a single image/input tensor with D
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment