Add training with white backgrounds

This commit is contained in:
Matt Tancik committed 2022-05-04 13:45:53 -07:00
1 parent 4ce6e6859a
commit ba28d0cdb2
7 files changed
+55 -17

No files matched your search

+12 -2
View File
@@ -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