Fix slow training issue when using mask (#1114)

This commit is contained in:
Tao authored and GitHub committed 2022-12-13 10:16:34 -08:00
1 parent 98f13cbed4
commit 1a70665e76
1 file changed
+1 -1
+1 -1
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].to(device), as_tuple=False)
nonzero_indices = torch.nonzero(batch["mask"][..., 0], as_tuple=False)
chosen_indices = random.sample(range(len(nonzero_indices)), k=num_rays_per_batch)
indices = nonzero_indices[chosen_indices]
else: