From 22dae34eeb41e1ac38141a4bead4f007d97e9652 Mon Sep 17 00:00:00 2001 From: Hoanh Le <52367731+hoanhle@users.noreply.github.com> Date: Wed, 28 Aug 2024 22:37:54 +0300 Subject: [PATCH] add assertion to make sure positions and positions_flat are not empty (#3387) --- .pre-commit-config.yaml | 2 +- nerfstudio/fields/nerfacto_field.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bdb8ff4f4..a93cfbd1f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.1.13 + rev: v0.6.2 hooks: - id: ruff types_or: [ python, pyi, jupyter ] diff --git a/nerfstudio/fields/nerfacto_field.py b/nerfstudio/fields/nerfacto_field.py index 5b3af8b55..5cf8b5771 100644 --- a/nerfstudio/fields/nerfacto_field.py +++ b/nerfstudio/fields/nerfacto_field.py @@ -211,10 +211,15 @@ class NerfactoField(Field): # Make sure the tcnn gets inputs between 0 and 1. selector = ((positions > 0.0) & (positions < 1.0)).all(dim=-1) positions = positions * selector[..., None] + + assert positions.numel() > 0, "positions is empty." + self._sample_locations = positions if not self._sample_locations.requires_grad: self._sample_locations.requires_grad = True 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) density_before_activation, base_mlp_out = torch.split(h, [1, self.geo_feat_dim], dim=-1) self._density_before_activation = density_before_activation