From df36223ddf3b0bb75b9d9c080c5fe5dd940de34b Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Tue, 6 Sep 2022 10:28:45 -0700 Subject: [PATCH] raysampling stratified_sampling doc Summary: Followup to D39259775 (https://github.com/facebookresearch/pytorch3d/commit/438c194ec61b34b377727c97d5922897546c581d) Reviewed By: davnov134 Differential Revision: D39271753 fbshipit-source-id: 5cf11c1210369e1762ef0d5d0c7b60336711b261 --- pytorch3d/renderer/implicit/raysampling.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pytorch3d/renderer/implicit/raysampling.py b/pytorch3d/renderer/implicit/raysampling.py index 8d5944656..fb55ba7b8 100644 --- a/pytorch3d/renderer/implicit/raysampling.py +++ b/pytorch3d/renderer/implicit/raysampling.py @@ -89,7 +89,7 @@ def __init__( max_depth: The maximum depth of a ray-point. n_rays_per_image: If given, this amount of rays are sampled from the grid. unit_directions: whether to normalize direction vectors in ray bundle. - stratified_sampling: if set, performs stratified random sampling + stratified_sampling: if True, performs stratified random sampling along the ray; otherwise takes ray points at deterministic offsets. """ super().__init__() @@ -136,9 +136,8 @@ def forward( max_depth: The maximum depth of a ray-point. n_rays_per_image: If given, this amount of rays are sampled from the grid. n_pts_per_ray: The number of points sampled along each ray. - stratified_sampling: if set, performs stratified sampling in n_pts_per_ray - bins for each ray; otherwise takes n_pts_per_ray deterministic points - on each ray with uniform offsets. + stratified_sampling: if set, overrides stratified_sampling provided + in __init__. Returns: A named tuple RayBundle with the following fields: origins: A tensor of shape @@ -296,7 +295,7 @@ def __init__( min_depth: The minimum depth of each ray-point. max_depth: The maximum depth of each ray-point. unit_directions: whether to normalize direction vectors in ray bundle. - stratified_sampling: if set, performs stratified sampling in n_pts_per_ray + stratified_sampling: if True, performs stratified sampling in n_pts_per_ray bins for each ray; otherwise takes n_pts_per_ray deterministic points on each ray with uniform offsets. """ @@ -322,9 +321,9 @@ def forward( """ Args: cameras: A batch of `batch_size` cameras from which the rays are emitted. - stratified_sampling: if set, performs stratified sampling in n_pts_per_ray - bins for each ray; otherwise takes n_pts_per_ray deterministic points - on each ray with uniform offsets. + stratified_sampling: if set, overrides stratified_sampling provided + in __init__. + Returns: A named tuple RayBundle with the following fields: origins: A tensor of shape @@ -514,7 +513,7 @@ def _xy_to_ray_bundle( max_depth: The maximum depth of each ray-point. n_pts_per_ray: The number of points sampled along each ray. unit_directions: whether to normalize direction vectors in ray bundle. - stratified_sampling: if set, performs stratified sampling in n_pts_per_ray + stratified_sampling: if True, performs stratified sampling in n_pts_per_ray bins for each ray; otherwise takes n_pts_per_ray deterministic points on each ray with uniform offsets. """ @@ -583,7 +582,7 @@ def _jiggle_within_stratas(bin_centers: torch.Tensor) -> torch.Tensor: More specifically, it replaces each point's value `z` with a sample from a uniform random distribution on - `[z - delta_−, z + delta_+]`, where `delta_−` is half of the difference + `[z - delta_-, z + delta_+]`, where `delta_-` is half of the difference between `z` and the previous point, and `delta_+` is half of the difference between the next point and `z`. For the first and last items, the corresponding boundary deltas are assumed zero.