From a8d5990e272f063b6a87da9d85df21346344b5c5 Mon Sep 17 00:00:00 2001 From: Aaryan Chandna Date: Sun, 15 Jun 2025 18:25:58 -0700 Subject: [PATCH 1/8] added functionality for indices eval-mode --- .../data/dataparsers/nerfstudio_dataparser.py | 7 ++++++- nerfstudio/data/utils/dataparsers_utils.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/nerfstudio/data/dataparsers/nerfstudio_dataparser.py b/nerfstudio/data/dataparsers/nerfstudio_dataparser.py index 24dc456d1..d92282755 100644 --- a/nerfstudio/data/dataparsers/nerfstudio_dataparser.py +++ b/nerfstudio/data/dataparsers/nerfstudio_dataparser.py @@ -32,6 +32,7 @@ from nerfstudio.data.utils.dataparsers_utils import ( get_train_eval_split_filename, get_train_eval_split_fraction, get_train_eval_split_interval, + get_train_eval_split_indices ) from nerfstudio.utils.io import load_from_json from nerfstudio.utils.rich_utils import CONSOLE @@ -59,7 +60,7 @@ class NerfstudioDataParserConfig(DataParserConfig): """The method to use to center the poses.""" auto_scale_poses: bool = True """Whether to automatically scale the poses to fit in +/- 1 bounding box.""" - eval_mode: Literal["fraction", "filename", "interval", "all"] = "fraction" + eval_mode: Literal["fraction", "filename", "interval", "all", "indices"] = "fraction" """ The method to use for splitting the dataset into train and eval. Fraction splits based on a percentage for train and the remaining for eval. @@ -77,6 +78,8 @@ class NerfstudioDataParserConfig(DataParserConfig): """Replace the unknown pixels with this color. Relevant if you have a mask but still sample everywhere.""" load_3D_points: bool = False """Whether to load the 3D points from the colmap reconstruction.""" + eval_image_indices: Tuple[int, ...] = (0,) + """Specifies the image indices to use during eval; if None, uses all.""" @dataclass @@ -212,6 +215,8 @@ class Nerfstudio(DataParser): i_train, i_eval = get_train_eval_split_filename(image_filenames) elif self.config.eval_mode == "interval": i_train, i_eval = get_train_eval_split_interval(image_filenames, self.config.eval_interval) + elif self.config.eval_mode == "indices": + i_train, i_eval = get_train_eval_split_indices(image_filenames, self.config.eval_image_indices) elif self.config.eval_mode == "all": CONSOLE.log( "[yellow] Be careful with '--eval-mode=all'. If using camera optimization, the cameras may diverge in the current implementation, giving unpredictable results." diff --git a/nerfstudio/data/utils/dataparsers_utils.py b/nerfstudio/data/utils/dataparsers_utils.py index 0c79cbde1..12ac73ee0 100644 --- a/nerfstudio/data/utils/dataparsers_utils.py +++ b/nerfstudio/data/utils/dataparsers_utils.py @@ -99,3 +99,21 @@ def get_train_eval_split_all(image_filenames: List) -> Tuple[np.ndarray, np.ndar i_train = i_all i_eval = i_all return i_train, i_eval + +def get_train_eval_split_indices(image_filenames: List, eval_image_indices: Tuple[int, ...]) -> Tuple[np.ndarray, np.ndarray]: + """ + Get the train/eval split based on specified indices in the config. + + Args: + image_filenames: list of image filenames + eval_image_indices: Tuple of indices to use for evaluation. + """ + for idx in eval_image_indices: + if idx >= len(image_filenames) or idx < 0: + raise ValueError(f"Eval index {idx} is out of bounds for the number of images {len(image_filenames)}.") + all_indices = set(range(len(image_filenames))) + eval_indices = set(eval_image_indices) + train_indices = all_indices - eval_indices + + return np.array(sorted(train_indices)), np.array(sorted(eval_indices)) + From aeafdafa57d9a01423373b4c942a76feb07342cb Mon Sep 17 00:00:00 2001 From: Aaryan Chandna Date: Sun, 15 Jun 2025 19:10:32 -0700 Subject: [PATCH 2/8] reformat --- nerfstudio/data/dataparsers/nerfstudio_dataparser.py | 2 +- nerfstudio/data/utils/dataparsers_utils.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nerfstudio/data/dataparsers/nerfstudio_dataparser.py b/nerfstudio/data/dataparsers/nerfstudio_dataparser.py index d92282755..2539a4aa0 100644 --- a/nerfstudio/data/dataparsers/nerfstudio_dataparser.py +++ b/nerfstudio/data/dataparsers/nerfstudio_dataparser.py @@ -31,8 +31,8 @@ from nerfstudio.data.utils.dataparsers_utils import ( get_train_eval_split_all, get_train_eval_split_filename, get_train_eval_split_fraction, + get_train_eval_split_indices, get_train_eval_split_interval, - get_train_eval_split_indices ) from nerfstudio.utils.io import load_from_json from nerfstudio.utils.rich_utils import CONSOLE diff --git a/nerfstudio/data/utils/dataparsers_utils.py b/nerfstudio/data/utils/dataparsers_utils.py index 12ac73ee0..7e8e7bfff 100644 --- a/nerfstudio/data/utils/dataparsers_utils.py +++ b/nerfstudio/data/utils/dataparsers_utils.py @@ -100,7 +100,10 @@ def get_train_eval_split_all(image_filenames: List) -> Tuple[np.ndarray, np.ndar i_eval = i_all return i_train, i_eval -def get_train_eval_split_indices(image_filenames: List, eval_image_indices: Tuple[int, ...]) -> Tuple[np.ndarray, np.ndarray]: + +def get_train_eval_split_indices( + image_filenames: List, eval_image_indices: Tuple[int, ...] +) -> Tuple[np.ndarray, np.ndarray]: """ Get the train/eval split based on specified indices in the config. @@ -116,4 +119,3 @@ def get_train_eval_split_indices(image_filenames: List, eval_image_indices: Tupl train_indices = all_indices - eval_indices return np.array(sorted(train_indices)), np.array(sorted(eval_indices)) - From d695e0d080f861bea60e1bbbd0cd59072da22a54 Mon Sep 17 00:00:00 2001 From: basebala Date: Tue, 7 Jul 2026 22:51:06 -0700 Subject: [PATCH 3/8] Change error from array to float in test cases --- tests/process_data/test_process_images.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/process_data/test_process_images.py b/tests/process_data/test_process_images.py index b27346c68..86f188d97 100644 --- a/tests/process_data/test_process_images.py +++ b/tests/process_data/test_process_images.py @@ -59,7 +59,7 @@ def test_process_images_skip_colmap(tmp_path: Path): id=1, xyz=np.array([0, 0, 0]), rgb=np.array([0, 0, 0]), - error=np.array([0]), + error=0.0, image_ids=np.array([1]), point2D_idxs=np.array([0]), ), @@ -144,7 +144,7 @@ def test_process_images_recursively_skip_colmap(tmp_path: Path): id=1, xyz=np.array([0, 0, 0]), rgb=np.array([0, 0, 0]), - error=np.array([0]), + error=0.0, image_ids=np.array([1]), point2D_idxs=np.array([0]), ), From ff0815c0c810e40d3877aefaf65d02df938a710c Mon Sep 17 00:00:00 2001 From: basebala Date: Wed, 8 Jul 2026 10:12:20 -0700 Subject: [PATCH 4/8] Update Dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6cd4e058f..767aa17f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -81,7 +81,8 @@ RUN git clone https://github.com/colmap/colmap.git && \ # Upgrade pip and install dependencies. # pip install torch==2.2.2 torchvision==0.17.2 --index-url https://download.pytorch.org/whl/cu118 && \ -RUN pip install --no-cache-dir --upgrade pip 'setuptools<70.0.0' && \ +RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \ + pip install --no-cache-dir 'setuptools<70.0.0' && \ pip install --no-cache-dir torch==2.1.2+cu118 torchvision==0.16.2+cu118 'numpy<2.0.0' --extra-index-url https://download.pytorch.org/whl/cu118 && \ git clone --branch master --recursive https://github.com/cvg/Hierarchical-Localization.git /opt/hloc && \ cd /opt/hloc && git checkout v1.4 && python3.10 -m pip install --no-cache-dir . && cd ~ && \ From 2c66c8b6c9481da0c60716753ab9b1612822f83f Mon Sep 17 00:00:00 2001 From: basebala Date: Wed, 8 Jul 2026 16:44:59 -0700 Subject: [PATCH 5/8] Modify tiny-cuda-nn installation command in Dockerfile Updated pip install command for tiny-cuda-nn to include --no-build-isolation. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 767aa17f3..eb3809ed2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,7 +86,7 @@ RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \ pip install --no-cache-dir torch==2.1.2+cu118 torchvision==0.16.2+cu118 'numpy<2.0.0' --extra-index-url https://download.pytorch.org/whl/cu118 && \ git clone --branch master --recursive https://github.com/cvg/Hierarchical-Localization.git /opt/hloc && \ cd /opt/hloc && git checkout v1.4 && python3.10 -m pip install --no-cache-dir . && cd ~ && \ - TCNN_CUDA_ARCHITECTURES="${CUDA_ARCHITECTURES}" pip install --no-cache-dir "git+https://github.com/NVlabs/tiny-cuda-nn.git@b3473c81396fe927293bdfd5a6be32df8769927c#subdirectory=bindings/torch" && \ + TCNN_CUDA_ARCHITECTURES="${CUDA_ARCHITECTURES}" pip install --no-cache-dir --no-build-isolation "git+https://github.com/NVlabs/tiny-cuda-nn.git@b3473c81396fe927293bdfd5a6be32df8769927c#subdirectory=bindings/torch" && \ pip install --no-cache-dir pycolmap==0.6.1 pyceres==2.1 omegaconf==2.3.0 # Install gsplat and nerfstudio. From ccee256535129dd1980df47910277bd0916a22f1 Mon Sep 17 00:00:00 2001 From: basebala Date: Wed, 8 Jul 2026 19:16:16 -0700 Subject: [PATCH 6/8] Update Dockerfile to install specific torch versions --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index eb3809ed2..0b6451a80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,6 +98,7 @@ RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \ COPY --from=source /tmp/nerfstudio/ /tmp/nerfstudio RUN export TORCH_CUDA_ARCH_LIST="$(echo "$CUDA_ARCHITECTURES" | tr ';' '\n' | awk '$0 > 70 {print substr($0,1,1)"."substr($0,2)}' | tr '\n' ' ' | sed 's/ $//')" && \ export MAX_JOBS=4 && \ + pip install --no-cache-dir torch==2.1.2+cu118 torchvision==0.16.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118 && \ GSPLAT_VERSION="$(sed -n 's/.*gsplat==\s*\([^," '"'"']*\).*/\1/p' /tmp/nerfstudio/pyproject.toml)" && \ pip install --no-cache-dir git+https://github.com/nerfstudio-project/gsplat.git@v${GSPLAT_VERSION} && \ pip install --no-cache-dir /tmp/nerfstudio 'numpy<2.0.0' && \ From 501e5e2284222c05280a0ec4f58cd55098396719 Mon Sep 17 00:00:00 2001 From: basebala Date: Wed, 8 Jul 2026 21:46:16 -0700 Subject: [PATCH 7/8] Enhance Dockerfile with package installations Updated the Dockerfile to install additional Python packages and upgrade setuptools. --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 0b6451a80..41e9f9064 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,6 +99,7 @@ COPY --from=source /tmp/nerfstudio/ /tmp/nerfstudio RUN export TORCH_CUDA_ARCH_LIST="$(echo "$CUDA_ARCHITECTURES" | tr ';' '\n' | awk '$0 > 70 {print substr($0,1,1)"."substr($0,2)}' | tr '\n' ' ' | sed 's/ $//')" && \ export MAX_JOBS=4 && \ pip install --no-cache-dir torch==2.1.2+cu118 torchvision==0.16.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118 && \ + pip install --upgrade setuptools && \ GSPLAT_VERSION="$(sed -n 's/.*gsplat==\s*\([^," '"'"']*\).*/\1/p' /tmp/nerfstudio/pyproject.toml)" && \ pip install --no-cache-dir git+https://github.com/nerfstudio-project/gsplat.git@v${GSPLAT_VERSION} && \ pip install --no-cache-dir /tmp/nerfstudio 'numpy<2.0.0' && \ From 50b2f0349f304377e86b53470183d5c9d3b00d9d Mon Sep 17 00:00:00 2001 From: basebala Date: Thu, 9 Jul 2026 09:56:36 -0700 Subject: [PATCH 8/8] Update pip install command for gsplat package --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 41e9f9064..be9e45cd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -101,7 +101,7 @@ RUN export TORCH_CUDA_ARCH_LIST="$(echo "$CUDA_ARCHITECTURES" | tr ';' '\n' | aw pip install --no-cache-dir torch==2.1.2+cu118 torchvision==0.16.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118 && \ pip install --upgrade setuptools && \ GSPLAT_VERSION="$(sed -n 's/.*gsplat==\s*\([^," '"'"']*\).*/\1/p' /tmp/nerfstudio/pyproject.toml)" && \ - pip install --no-cache-dir git+https://github.com/nerfstudio-project/gsplat.git@v${GSPLAT_VERSION} && \ + pip install --no-cache-dir --no-build-isolation git+https://github.com/nerfstudio-project/gsplat.git@v${GSPLAT_VERSION} && \ pip install --no-cache-dir /tmp/nerfstudio 'numpy<2.0.0' && \ rm -rf /tmp/nerfstudio