mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-03 14:28:41 +08:00
Add training with white backgrounds
This commit is contained in:
1 parent
4ce6e6859a
commit
ba28d0cdb2
7 files changed
+55
-17
No files matched your search
@@ -19,9 +19,16 @@ class RendererOutputs:
|
||||
class RGBRenderer(nn.Module):
|
||||
"""Standard volumetic rendering."""
|
||||
|
||||
@classmethod
|
||||
def __init__(self, white_background: bool = False) -> None:
|
||||
"""
|
||||
Args:
|
||||
white_background (bool, optional): Composite onto white. Defaults to True.
|
||||
"""
|
||||
super().__init__()
|
||||
self.white_background = white_background
|
||||
|
||||
def forward(
|
||||
cls,
|
||||
self,
|
||||
rgb: TensorType[..., "num_samples", 3],
|
||||
weights: TensorType[..., "num_samples"],
|
||||
) -> RendererOutputs:
|
||||
@@ -37,5 +44,8 @@ class RGBRenderer(nn.Module):
|
||||
|
||||
rgb = torch.sum(weights[..., None] * rgb, dim=-2)
|
||||
|
||||
if self.white_background:
|
||||
rgb = rgb + (1.0 - torch.sum(weights, dim=-1))[..., None]
|
||||
|
||||
renderer_outputs = RendererOutputs(rgb=rgb)
|
||||
return renderer_outputs
|
||||
Reference in new issue
Block a user