From 59d6acf9da718d1d513d260b8808a9bed1bbbd39 Mon Sep 17 00:00:00 2001 From: Maxime Vandegar <45870423+MaximeVandegar@users.noreply.github.com> Date: Sun, 31 Mar 2024 19:26:11 +0200 Subject: [PATCH] Exporting Splatfacto: correct errors when there are NaN/Inf values in some attributes (#3032) * Apply the mask on the proper axis for removing NaN/Inf values * Remove unnecessary indexing which raises an error for 1-d arrays * Update the number of gaussians after removing NaN/Inf values --- nerfstudio/scripts/exporter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nerfstudio/scripts/exporter.py b/nerfstudio/scripts/exporter.py index 180da81f9..467ad88f3 100644 --- a/nerfstudio/scripts/exporter.py +++ b/nerfstudio/scripts/exporter.py @@ -582,7 +582,7 @@ class ExportGaussianSplat(Exporter): select = np.ones(n, dtype=bool) for k, t in map_to_tensors.items(): n_before = np.sum(select) - select = np.logical_and(select, np.isfinite(t).all()) + select = np.logical_and(select, np.isfinite(t).all(axis=-1)) n_after = np.sum(select) if n_after < n_before: CONSOLE.print(f"{n_before - n_after} NaN/Inf elements in {k}") @@ -590,7 +590,8 @@ class ExportGaussianSplat(Exporter): if np.sum(select) < n: CONSOLE.print(f"values have NaN/Inf in map_to_tensors, only export {np.sum(select)}/{n}") for k, t in map_to_tensors.items(): - map_to_tensors[k] = map_to_tensors[k][select, :] + map_to_tensors[k] = map_to_tensors[k][select] + count = np.sum(select) ExportGaussianSplat.write_ply(str(filename), count, map_to_tensors)