Make background_color a required argument in blend_background

This commit is contained in:
Nicholas Pfaff committed 2023-07-04 16:25:20 +01:00
1 parent e24f15baad
commit c15fa1819d
1 file changed
+2 -4
+2 -4
View File
@@ -133,7 +133,7 @@ class RGBRenderer(nn.Module):
cls, cls,
rgb: Tensor, rgb: Tensor,
opacity: Tensor, opacity: Tensor,
background_color: Optional[Tensor] = None, background_color: Tensor,
) -> Float[Tensor, "*bs 3"]: ) -> Float[Tensor, "*bs 3"]:
"""Blends the background color into the image. """Blends the background color into the image.
@@ -147,9 +147,7 @@ class RGBRenderer(nn.Module):
""" """
if len(opacity.shape) == 1: if len(opacity.shape) == 1:
opacity = opacity.unsqueeze(-1) opacity = opacity.unsqueeze(-1)
blended_rgb = ( blended_rgb = rgb * opacity + background_color.to(rgb.device) * (1 - opacity)
rgb * opacity + background_color.to(rgb.device) * (1 - opacity) if background_color is not None else rgb
)
return blended_rgb return blended_rgb
def forward( def forward(