Skip to content

Commit 69b27d1

Browse files
bottlerfacebook-github-bot
authored andcommitted
reallow scalar background color for point rendering
Summary: A scalar background color is not meant to be allowed for the point renderer. It used to be ignored with a warning, but a recent code change made it an error. It was being used, at least in the black (value=0.0) case. Re-enable it. Reviewed By: nikhilaravi Differential Revision: D34519651 fbshipit-source-id: d37dcf145bb7b8999c9265cf8fc39b084059dd18
1 parent 84a569c commit 69b27d1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pytorch3d/renderer/points/compositor.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
import warnings
87
from typing import List, Optional, Tuple, Union
98

109
import torch
@@ -85,7 +84,10 @@ def _add_background_color_to_images(pix_idxs, images, background_color):
8584
if not torch.is_tensor(background_color):
8685
background_color = images.new_tensor(background_color)
8786

88-
if len(background_color.shape) != 1:
87+
if background_color.ndim == 0:
88+
background_color = background_color.expand(images.shape[1])
89+
90+
if background_color.ndim > 1:
8991
raise ValueError("Wrong shape of background_color")
9092

9193
background_color = background_color.to(images)
@@ -98,7 +100,8 @@ def _add_background_color_to_images(pix_idxs, images, background_color):
98100

99101
if images.shape[1] != background_color.shape[0]:
100102
raise ValueError(
101-
f"background color has {background_color.shape[0] } channels not {images.shape[1]}"
103+
"Background color has %s channels not %s"
104+
% (background_color.shape[0], images.shape[1])
102105
)
103106

104107
num_background_pixels = background_mask.sum()

0 commit comments

Comments
 (0)