Skip to content

Commit

Permalink
filter low opacities when exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
jb-ye authored and Jianbo Ye committed Aug 26, 2024
1 parent c2ec812 commit 6b7f3c5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion nerfstudio/scripts/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,17 @@ def main(self) -> None:
n_after = np.sum(select)
if n_after < n_before:
CONSOLE.print(f"{n_before - n_after} NaN/Inf elements in {k}")
nan_count = np.sum(select) - n

# filter gaussians that have opacities < 1/255, because they are skipped in cuda rasterization
low_opacity_gaussians = (map_to_tensors["opacity"]).squeeze(axis=-1) < -5.5373 # logit(1/255)
lowopa_count = np.sum(low_opacity_gaussians)
select[low_opacity_gaussians] = 0

if np.sum(select) < n:
CONSOLE.print(f"values have NaN/Inf in map_to_tensors, only export {np.sum(select)}/{n}")
CONSOLE.print(
f"{nan_count} Gaussians have NaN/Inf and {lowopa_count} have low opacity, only export {np.sum(select)}/{n}"
)
for k, t in map_to_tensors.items():
map_to_tensors[k] = map_to_tensors[k][select]
count = np.sum(select)
Expand Down

0 comments on commit 6b7f3c5

Please sign in to comment.