Skip to content

Commit 8f3c5c5

Browse files
committed
plumb to python and add pytests with backgrounds
Signed-off-by: Mark Harris <mharris@nvidia.com>
1 parent 07f5941 commit 8f3c5c5

File tree

5 files changed

+386
-3
lines changed

5 files changed

+386
-3
lines changed

fvdb/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def gaussian_render_jagged(
108108
render_depth_channel: bool = False,
109109
return_debug_info: bool = False,
110110
ortho: bool = False,
111+
backgrounds: torch.Tensor | None = None,
111112
) -> tuple[torch.Tensor, torch.Tensor, dict[str, torch.Tensor]]:
112113
return _gaussian_render_jagged_cpp(
113114
means=means._impl,
@@ -129,6 +130,7 @@ def gaussian_render_jagged(
129130
render_depth_channel=render_depth_channel,
130131
return_debug_info=return_debug_info,
131132
ortho=ortho,
133+
backgrounds=backgrounds,
132134
)
133135

134136

fvdb/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ def gaussian_render_jagged(
9090
return_debug_info: bool = False,
9191
render_depth_only: bool = False,
9292
ortho: bool = False,
93-
) -> JaggedTensor: ...
93+
backgrounds: torch.Tensor | None = None,
94+
) -> tuple[torch.Tensor, torch.Tensor, dict[str, torch.Tensor]]: ...
9495
@overload
9596
def jcat(grid_batches: Sequence[GridBatch]) -> GridBatch: ...
9697
@overload

fvdb/_fvdb_cpp.pyi

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
import typing
55
from enum import Enum
6-
from typing import ClassVar, overload
6+
from typing import ClassVar, Optional, overload
77

88
import torch
99

@@ -165,6 +165,7 @@ class GaussianSplat3d:
165165
min_radius_2d: float = ...,
166166
eps_2d: float = ...,
167167
antialias: bool = ...,
168+
backgrounds: Optional[torch.Tensor] = ...,
168169
) -> tuple[torch.Tensor, torch.Tensor]: ...
169170
def render_from_projected_gaussians(
170171
self,
@@ -174,6 +175,7 @@ class GaussianSplat3d:
174175
crop_origin_w: int = ...,
175176
crop_origin_h: int = ...,
176177
tile_size: int = ...,
178+
backgrounds: Optional[torch.Tensor] = ...,
177179
) -> tuple[torch.Tensor, torch.Tensor]: ...
178180
def render_images(
179181
self,
@@ -189,6 +191,7 @@ class GaussianSplat3d:
189191
min_radius_2d: float = ...,
190192
eps_2d: float = ...,
191193
antialias: bool = ...,
194+
backgrounds: Optional[torch.Tensor] = ...,
192195
) -> tuple[torch.Tensor, torch.Tensor]: ...
193196
def render_images_and_depths(
194197
self,
@@ -204,6 +207,7 @@ class GaussianSplat3d:
204207
min_radius_2d: float = ...,
205208
eps_2d: float = ...,
206209
antialias: bool = ...,
210+
backgrounds: Optional[torch.Tensor] = ...,
207211
) -> tuple[torch.Tensor, torch.Tensor]: ...
208212
def render_num_contributing_gaussians(
209213
self,
@@ -1037,7 +1041,29 @@ class config:
10371041
pedantic_error_checking: ClassVar[bool] = ...
10381042
def __init__(self, *args, **kwargs) -> None: ...
10391043

1040-
def gaussian_render_jagged(*args, **kwargs): ...
1044+
def gaussian_render_jagged(
1045+
means: JaggedTensor,
1046+
quats: JaggedTensor,
1047+
scales: JaggedTensor,
1048+
opacities: JaggedTensor,
1049+
sh_coeffs: JaggedTensor,
1050+
viewmats: JaggedTensor,
1051+
Ks: JaggedTensor,
1052+
image_width: int,
1053+
image_height: int,
1054+
near_plane: float = ...,
1055+
far_plane: float = ...,
1056+
sh_degree_to_use: int = ...,
1057+
tile_size: int = ...,
1058+
radius_clip: float = ...,
1059+
eps2d: float = ...,
1060+
antialias: bool = ...,
1061+
render_depth_channel: bool = ...,
1062+
return_debug_info: bool = ...,
1063+
render_depth_only: bool = ...,
1064+
ortho: bool = ...,
1065+
backgrounds: Optional[torch.Tensor] = ...,
1066+
) -> tuple[torch.Tensor, torch.Tensor, dict[str, torch.Tensor]]: ...
10411067
@overload
10421068
def gridbatch_from_dense(
10431069
num_grids: int,

fvdb/gaussian_splatting.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,7 @@ def render_from_projected_gaussians(
15291529
crop_origin_w: int = -1,
15301530
crop_origin_h: int = -1,
15311531
tile_size: int = 16,
1532+
backgrounds: torch.Tensor | None = None,
15321533
) -> tuple[torch.Tensor, torch.Tensor]:
15331534
"""
15341535
Render a set of images from Gaussian splats that have already been projected onto image planes
@@ -1613,6 +1614,7 @@ def render_from_projected_gaussians(
16131614
crop_origin_w=crop_origin_w,
16141615
crop_origin_h=crop_origin_h,
16151616
tile_size=tile_size,
1617+
backgrounds=backgrounds,
16161618
)
16171619

16181620
def render_depths(
@@ -1628,6 +1630,7 @@ def render_depths(
16281630
min_radius_2d: float = 0.3,
16291631
eps_2d: float = 0.3,
16301632
antialias: bool = False,
1633+
backgrounds: torch.Tensor | None = None,
16311634
) -> tuple[torch.Tensor, torch.Tensor]:
16321635
"""
16331636
Render ``C`` depth maps from this :class:`GaussianSplat3d` from ``C`` camera views.
@@ -1693,6 +1696,7 @@ def render_depths(
16931696
min_radius_2d=min_radius_2d,
16941697
eps_2d=eps_2d,
16951698
antialias=antialias,
1699+
backgrounds=backgrounds,
16961700
)
16971701

16981702
def render_images(
@@ -1709,6 +1713,7 @@ def render_images(
17091713
min_radius_2d: float = 0.0,
17101714
eps_2d: float = 0.3,
17111715
antialias: bool = False,
1716+
backgrounds: torch.Tensor | None = None,
17121717
) -> tuple[torch.Tensor, torch.Tensor]:
17131718
"""
17141719
Render ``C`` multi-channel images (see :attr:`num_channels`) from this :class:`GaussianSplat3d` from ``C`` camera views.
@@ -1775,6 +1780,7 @@ def render_images(
17751780
min_radius_2d=min_radius_2d,
17761781
eps_2d=eps_2d,
17771782
antialias=antialias,
1783+
backgrounds=backgrounds,
17781784
)
17791785

17801786
def render_images_and_depths(
@@ -1791,6 +1797,7 @@ def render_images_and_depths(
17911797
min_radius_2d: float = 0.0,
17921798
eps_2d: float = 0.3,
17931799
antialias: bool = False,
1800+
backgrounds: torch.Tensor | None = None,
17941801
) -> tuple[torch.Tensor, torch.Tensor]:
17951802
"""
17961803
Render ``C`` multi-channel images (see :attr:`num_channels`) with depth as the last channel from this :class:`GaussianSplat3d` from ``C`` camera views.
@@ -1861,6 +1868,7 @@ def render_images_and_depths(
18611868
min_radius_2d=min_radius_2d,
18621869
eps_2d=eps_2d,
18631870
antialias=antialias,
1871+
backgrounds=backgrounds,
18641872
)
18651873

18661874
def render_num_contributing_gaussians(

0 commit comments

Comments
 (0)