Datasets:
Formats:
parquet
Size:
1M - 10M
Tags:
gaussian-splatting
fault-tolerance
single-event-upset
reliability
radiance-fields
computer-graphics
License:
| """3D Gaussian Splatting model container and rendering, on top of gsplat. | |
| Parameters are stored in their optimization spaces (scales in log, opacities in | |
| logit) to match gsplat's DefaultStrategy expectations. Field layout: | |
| means [N,3] float | |
| scales [N,3] log-scale | |
| quats [N,4] (normalized internally by gsplat) | |
| opacities [N] logit | |
| sh0 [N,1,3] SH DC term | |
| shN [N,M,3] SH higher-order terms, M = (sh_degree+1)^2 - 1 | |
| """ | |
| from typing import Dict, Tuple | |
| import torch | |
| from gsplat import rasterization | |
| # canonical ordering of fields and the per-field component counts | |
| FIELDS = ["means", "scales", "quats", "opacities", "sh0", "shN"] | |
| def colors_from_params(params: Dict[str, torch.Tensor]) -> torch.Tensor: | |
| return torch.cat([params["sh0"], params["shN"]], dim=1) # [N, K, 3] | |
| def render(params: Dict[str, torch.Tensor], viewmats: torch.Tensor, Ks: torch.Tensor, | |
| W: int, H: int, sh_degree: int, bg_white: bool = True, | |
| packed: bool = True, absgrad: bool = False) -> Tuple[torch.Tensor, torch.Tensor, dict]: | |
| """Render C cameras. Returns (renders[C,H,W,3] clamped to [0,1], alphas, info).""" | |
| colors = colors_from_params(params) | |
| renders, alphas, info = rasterization( | |
| params["means"], params["quats"], torch.exp(params["scales"]), | |
| torch.sigmoid(params["opacities"]), colors, viewmats, Ks, W, H, | |
| sh_degree=sh_degree, packed=packed, absgrad=absgrad, | |
| rasterize_mode="classic", | |
| ) | |
| # gsplat composites over black; composite over white using accumulated alpha. | |
| if bg_white: | |
| renders = renders + (1.0 - alphas) | |
| return renders, alphas, info | |
| def num_gaussians(params: Dict[str, torch.Tensor]) -> int: | |
| return params["means"].shape[0] | |