Shortcuts

mmedit.models.editors.eg3d.eg3d_utils

Module Contents

Functions

get_ray_limits_box(→ Tuple[torch.Tensor, torch.Tensor])

Author: Petr Kellnhofer

inverse_transform_sampling(→ torch.Tensor)

Sample N_importance samples from bins with distribution defined by

linspace_batch(→ torch.Tensor)

Creates a tensor of shape [num, *start.shape] whose values are evenly

mmedit.models.editors.eg3d.eg3d_utils.get_ray_limits_box(rays_o: torch.Tensor, rays_d: torch.Tensor, box_side_length: float) Tuple[torch.Tensor, torch.Tensor][源代码]

Author: Petr Kellnhofer Intersects rays with the [-1, 1] NDC volume. Returns min and max distance of entry. Returns -1 for no intersection. https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-box-intersection # noqa

参数
  • rays_o (torch.Tensor) – The origin of each ray.

  • rays_d (torch.Tensor) – The direction vector of each ray.

  • box_side_length (float) – The side length of axis aligned bounding box (AABB).

返回

Start and end point

for each ray. Both shape like (bz, res, res, 1).

返回类型

Tuple[torch.Tensor, torch.Tensor]

mmedit.models.editors.eg3d.eg3d_utils.inverse_transform_sampling(bins: torch.Tensor, weights: torch.Tensor, n_importance: int, deterministic: bool = False, eps: float = 1e-05) torch.Tensor[源代码]

Sample N_importance samples from bins with distribution defined by weights.

参数
  • bins (int) – (N_points, N_samples+1) where N_samples is the number of coarse samples per ray - 2.

  • weights (torch.Tensor) – Weights shape like (N_points, N_samples-1).

  • n_importance (int) – The number of samples to draw from the distribution.

  • deterministic (bool) – Whether use deterministic sampling method. Defaults to False.

  • eps (float) – a small number to prevent division by zero. Defaults to 1e-5.

Outputs:

torch.Tensor: the sampled samples.

mmedit.models.editors.eg3d.eg3d_utils.linspace_batch(start: torch.Tensor, stop: torch.Tensor, num: int) torch.Tensor[源代码]

Creates a tensor of shape [num, *start.shape] whose values are evenly spaced from start to end, inclusive.

Replicates but the multi-dimensional behaviour of numpy.linspace in PyTorch.

参数
  • start (torch.Tensor) – The start point of each ray. Shape like (bz, res, res, 1).

  • stop (torch.Tensor) – The end point of each ray. Shape like (bz, res, res, 1).

  • num (int) – The number of points to sample.

返回

The sampled points. Shape like (num, bz, res, res, 1)

返回类型

torch.Tensor

Read the Docs v: latest
Versions
master
latest
stable
zyh-doc-notfound-extend
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.