add assertion to make sure positions and positions_flat are not empty (#3387)

This commit is contained in:
Hoanh Le authored and GitHub committed 2024-08-28 12:37:54 -07:00
1 parent 69ae4abbfd
commit 22dae34eeb
2 files changed
+6 -1

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ repos:
- id: trailing-whitespace - id: trailing-whitespace
- id: end-of-file-fixer - id: end-of-file-fixer
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.13 rev: v0.6.2
hooks: hooks:
- id: ruff - id: ruff
types_or: [ python, pyi, jupyter ] types_or: [ python, pyi, jupyter ]
+5
View File
@@ -211,10 +211,15 @@ class NerfactoField(Field):
# Make sure the tcnn gets inputs between 0 and 1. # Make sure the tcnn gets inputs between 0 and 1.
selector = ((positions > 0.0) & (positions < 1.0)).all(dim=-1) selector = ((positions > 0.0) & (positions < 1.0)).all(dim=-1)
positions = positions * selector[..., None] positions = positions * selector[..., None]
assert positions.numel() > 0, "positions is empty."
self._sample_locations = positions self._sample_locations = positions
if not self._sample_locations.requires_grad: if not self._sample_locations.requires_grad:
self._sample_locations.requires_grad = True self._sample_locations.requires_grad = True
positions_flat = positions.view(-1, 3) positions_flat = positions.view(-1, 3)
assert positions_flat.numel() > 0, "positions_flat is empty."
h = self.mlp_base(positions_flat).view(*ray_samples.frustums.shape, -1) h = self.mlp_base(positions_flat).view(*ray_samples.frustums.shape, -1)
density_before_activation, base_mlp_out = torch.split(h, [1, self.geo_feat_dim], dim=-1) density_before_activation, base_mlp_out = torch.split(h, [1, self.geo_feat_dim], dim=-1)
self._density_before_activation = density_before_activation self._density_before_activation = density_before_activation