pytorch3d.implicitron.models.renderer.ray_point_refiner

ray_point_refiner

class pytorch3d.implicitron.models.renderer.ray_point_refiner.RayPointRefiner(*args, **kwargs)[source]

Bases: Configurable, Module

Implements the importance sampling of points along rays. The input is a RayBundle object with a ray_weights tensor which specifies the probabilities of sampling a point along each ray.

This raysampler is used for the fine rendering pass of NeRF. As such, the forward pass accepts the RayBundle output by the raysampling of the coarse rendering pass. Hence, it does not take cameras as input.

Parameters:
  • n_pts_per_ray – The number of points to sample along each ray.

  • random_sampling – If False, returns equispaced percentiles of the distribution defined by the input weights, otherwise performs sampling from that distribution.

  • add_input_samples – Concatenates and returns the sampled values together with the input samples.

  • blurpool_weights – Use blurpool defined in [1], on the input weights.

  • sample_pdf_eps – A constant preventing division by zero in case empty bins are present.

References

[1] Jonathan T. Barron, et al. “Mip-NeRF: A Multiscale Representation

for Anti-Aliasing Neural Radiance Fields.” ICCV 2021.

n_pts_per_ray: int
random_sampling: bool
add_input_samples: bool = True
blurpool_weights: bool = False
sample_pdf_eps: float = 1e-05
forward(input_ray_bundle: ImplicitronRayBundle, ray_weights: Tensor, blurpool_weights: bool = False, sample_pdf_padding: float = 1e-05, **kwargs) ImplicitronRayBundle[source]
Parameters:
  • input_ray_bundle – An instance of ImplicitronRayBundle specifying the source rays for sampling of the probability distribution.

  • ray_weights – A tensor of shape (…, input_ray_bundle.lengths.shape[-1]) with non-negative elements defining the probability distribution to sample ray points from.

  • blurpool_weights – Use blurpool defined in [1], on the input weights.

  • sample_pdf_padding – A constant preventing division by zero in case empty bins are present.

Returns:

ray_bundle

A new ImplicitronRayBundle instance containing the input ray

points together with n_pts_per_ray additionally sampled points per ray. For each ray, the lengths are sorted.

References

[1] Jonathan T. Barron, et al. “Mip-NeRF: A Multiscale Representation

for Anti-Aliasing Neural Radiance Fields.” ICCV 2021.

pytorch3d.implicitron.models.renderer.ray_point_refiner.apply_blurpool_on_weights(weights) Tensor[source]

Filter weights with a 2-tap max filters followed by a 2-tap blur filter, which produces a wide and smooth upper envelope on the weights.

Parameters:

weights – Tensor of shape (…, dim)

Returns:

blured_weights – Tensor of shape (…, dim)