Using volume sampling
Volume sampling is the process of getting color and occupancy information along the points provided by the ray samples. The volume representation we are working with is discrete. Therefore, the points defined in the ray sampling step might not fall exactly on a point. The nodes of the volume grids and points on rays typically have different spatial locations. We need to use an interpolation scheme to interpolate the densities and colors at points of rays from the densities and colors at volumes. We can do that by using VolumeSampler
implemented in PyTorch3D. The following code can be found in the GitHub repository in the understand_volume_sampler.py
file:
- Import the Python modules that we need:
import torch from pytorch3d.structures import Volumes from pytorch3d.renderer.implicit.renderer import VolumeSampler
- Set up the devices:
if torch.cuda.is_available(): Â Â Â Â device = torch.device("cuda:0") Â Â Â Â torch...