Skip to content

Commit 22dae34

Browse files
authored
add assertion to make sure positions and positions_flat are not empty (#3387)
1 parent 69ae4ab commit 22dae34

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repos:
1717
- id: trailing-whitespace
1818
- id: end-of-file-fixer
1919
- repo: https://github.com/charliermarsh/ruff-pre-commit
20-
rev: v0.1.13
20+
rev: v0.6.2
2121
hooks:
2222
- id: ruff
2323
types_or: [ python, pyi, jupyter ]

nerfstudio/fields/nerfacto_field.py

+5
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,15 @@ def get_density(self, ray_samples: RaySamples) -> Tuple[Tensor, Tensor]:
211211
# Make sure the tcnn gets inputs between 0 and 1.
212212
selector = ((positions > 0.0) & (positions < 1.0)).all(dim=-1)
213213
positions = positions * selector[..., None]
214+
215+
assert positions.numel() > 0, "positions is empty."
216+
214217
self._sample_locations = positions
215218
if not self._sample_locations.requires_grad:
216219
self._sample_locations.requires_grad = True
217220
positions_flat = positions.view(-1, 3)
221+
222+
assert positions_flat.numel() > 0, "positions_flat is empty."
218223
h = self.mlp_base(positions_flat).view(*ray_samples.frustums.shape, -1)
219224
density_before_activation, base_mlp_out = torch.split(h, [1, self.geo_feat_dim], dim=-1)
220225
self._density_before_activation = density_before_activation

0 commit comments

Comments
 (0)