MCPcopy
hub / github.com/nerfstudio-project/gsplat / compute_relocation

Function compute_relocation

gsplat/relocation.py:10–49  ·  view source on GitHub ↗

Compute new Gaussians from a set of old Gaussians. This function interprets the Gaussians as samples from a likelihood distribution. It uses the old opacities and scales to compute the new opacities and scales. This is an implementation of the paper `3D Gaussian Splatting as Markov

(
    opacities: Tensor,  # [N]
    scales: Tensor,  # [N, 3]
    ratios: Tensor,  # [N]
    binoms: Tensor,  # [n_max, n_max]
)

Source from the content-addressed store, hash-verified

8
9
10def compute_relocation(
11 opacities: Tensor, # [N]
12 scales: Tensor, # [N, 3]
13 ratios: Tensor, # [N]
14 binoms: Tensor, # [n_max, n_max]
15) -> Tuple[Tensor, Tensor]:
16 """Compute new Gaussians from a set of old Gaussians.
17
18 This function interprets the Gaussians as samples from a likelihood distribution.
19 It uses the old opacities and scales to compute the new opacities and scales.
20 This is an implementation of the paper
21 `3D Gaussian Splatting as Markov Chain Monte Carlo <https://arxiv.org/pdf/2404.09591>`_,
22
23 Args:
24 opacities: The opacities of the Gaussians. [N]
25 scales: The scales of the Gaussians. [N, 3]
26 ratios: The relative frequencies for each of the Gaussians. [N]
27 binoms: Precomputed lookup table for binomial coefficients used in
28 Equation 9 in the paper. [n_max, n_max]
29
30 Returns:
31 A tuple:
32
33 **new_opacities**: The opacities of the new Gaussians. [N]
34 **new_scales**: The scales of the Gaussians. [N, 3]
35 """
36
37 N = opacities.shape[0]
38 n_max, _ = binoms.shape
39 assert scales.shape == (N, 3), scales.shape
40 assert ratios.shape == (N,), ratios.shape
41 opacities = opacities.contiguous()
42 scales = scales.contiguous()
43 ratios.clamp_(min=1, max=n_max)
44 ratios = ratios.int().contiguous()
45
46 new_opacities, new_scales = _make_lazy_cuda_func("relocation")(
47 opacities, scales, ratios, binoms, n_max
48 )
49 return new_opacities, new_scales

Callers 2

relocateFunction · 0.90
sample_addFunction · 0.90

Calls 1

_make_lazy_cuda_funcFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…