4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 10:34:29 +08:00

Fix device mismatch error when using masks (#1061)

* Fix device mismatch error when using masks

* Update pixel_samplers.py
This commit is contained in:
hturki 2022-12-01 02:06:23 -05:00 committed by GitHub
parent 4c6cd352d8
commit 8c3f093ecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,7 @@ def collate_image_dataset_batch(batch: Dict, num_rays_per_batch: int, keep_full_
# only sample within the mask, if the mask is in the batch
if "mask" in batch:
nonzero_indices = torch.nonzero(batch["mask"][..., 0], as_tuple=False)
nonzero_indices = torch.nonzero(batch["mask"][..., 0].to(device), as_tuple=False)
chosen_indices = random.sample(range(len(nonzero_indices)), k=num_rays_per_batch)
indices = nonzero_indices[chosen_indices]
else: