From e2e5637d05fc281a28abe7c4f9c86a93e130a085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= <124616582+f-dy@users.noreply.github.com> Date: Fri, 9 Jun 2023 18:29:32 -0700 Subject: [PATCH] nerfstudio dataparser: avoid loading images at inference time (#2051) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also remove the image skipping logic, which seems to be a remnant of some old code (all images should exist) Co-authored-by: Frédéric Devernay --- nerfstudio/data/datamanagers/base_datamanager.py | 2 ++ nerfstudio/data/dataparsers/nerfstudio_dataparser.py | 12 ------------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/nerfstudio/data/datamanagers/base_datamanager.py b/nerfstudio/data/datamanagers/base_datamanager.py index 6b950de16..82e4f66d3 100644 --- a/nerfstudio/data/datamanagers/base_datamanager.py +++ b/nerfstudio/data/datamanagers/base_datamanager.py @@ -388,6 +388,8 @@ class VanillaDataManager(DataManager, Generic[TDataset]): else: self.config.data = self.config.dataparser.data self.dataparser = self.dataparser_config.setup() + if test_mode == "inference": + self.dataparser.downscale_factor = 1 # Avoid opening images self.includes_time = self.dataparser.includes_time self.train_dataparser_outputs: DataparserOutputs = self.dataparser.get_dataparser_outputs(split="train") diff --git a/nerfstudio/data/dataparsers/nerfstudio_dataparser.py b/nerfstudio/data/dataparsers/nerfstudio_dataparser.py index ea5012179..008fedfa2 100644 --- a/nerfstudio/data/dataparsers/nerfstudio_dataparser.py +++ b/nerfstudio/data/dataparsers/nerfstudio_dataparser.py @@ -85,7 +85,6 @@ class Nerfstudio(DataParser): mask_filenames = [] depth_filenames = [] poses = [] - num_skipped_image_filenames = 0 fx_fixed = "fl_x" in meta fy_fixed = "fl_y" in meta @@ -109,9 +108,6 @@ class Nerfstudio(DataParser): for frame in meta["frames"]: filepath = Path(frame["file_path"]) fname = self._get_fname(filepath, data_dir) - if not fname.exists(): - num_skipped_image_filenames += 1 - continue if not fx_fixed: assert "fl_x" in frame, "fx not specified in frame" @@ -159,14 +155,6 @@ class Nerfstudio(DataParser): depth_fname = self._get_fname(depth_filepath, data_dir, downsample_folder_prefix="depths_") depth_filenames.append(depth_fname) - if num_skipped_image_filenames >= 0: - CONSOLE.log(f"Skipping {num_skipped_image_filenames} files in dataset split {split}.") - assert ( - len(image_filenames) != 0 - ), """ - No image files found. - You should check the file_paths in the transforms.json file to make sure they are correct. - """ assert len(mask_filenames) == 0 or ( len(mask_filenames) == len(image_filenames) ), """