Skip to content

Commit

Permalink
Quick fix for mask None check (nerfstudio-project#1193)
Browse files Browse the repository at this point in the history
quick fix
  • Loading branch information
ethanweber authored and lucasthahn committed Jan 26, 2023
1 parent b018561 commit bf0b8ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nerfstudio/data/pixel_samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def sample_method( # pylint: disable=no-self-use
num_images: number of images to sample over
mask: mask of possible pixels in an image to sample from.
"""
if mask:
if isinstance(mask, torch.Tensor):
nonzero_indices = torch.nonzero(mask[..., 0], as_tuple=False)
chosen_indices = random.sample(range(len(nonzero_indices)), k=batch_size)
indices = nonzero_indices[chosen_indices]
Expand Down Expand Up @@ -222,7 +222,7 @@ def sample_method( # pylint: disable=no-self-use
device: Union[torch.device, str] = "cpu",
) -> TensorType["batch_size", 3]:

if mask:
if isinstance(mask, torch.Tensor):
# Note: if there is a mask, sampling reduces back to uniform sampling, which gives more
# sampling weight to the poles of the image than the equators.
# TODO(kevinddchen): implement the correct mask-sampling method.
Expand Down

0 comments on commit bf0b8ec

Please sign in to comment.