diff --git a/nerfstudio/data/dataparsers/record3d_dataparser.py b/nerfstudio/data/dataparsers/record3d_dataparser.py index bda09caee..ef20f21ba 100644 --- a/nerfstudio/data/dataparsers/record3d_dataparser.py +++ b/nerfstudio/data/dataparsers/record3d_dataparser.py @@ -41,7 +41,7 @@ class Record3DDataParserConfig(DataParserConfig): _target: Type = field(default_factory=lambda: Record3D) """target class to instantiate""" - data: Path = Path("data/record3d/garden") + data: Path = Path("data/record3d/bear") """Location of data""" val_skip: int = 8 """1/val_skip images to use for validation.""" @@ -49,7 +49,7 @@ class Record3DDataParserConfig(DataParserConfig): """Scene scale.""" orientation_method: Literal["pca", "up"] = "up" """The method to use for orientation""" - max_dataset_size: int = 150 + max_dataset_size: int = 300 """Max number of images to train on. If the dataset has more, images will be sampled approximately evenly.""" @@ -69,7 +69,7 @@ class Record3D(DataParser): image_filenames = [] for f in image_dir.iterdir(): if f.stem.isdigit(): # removes possible duplicate images (for example, 123(3).jpg) - image_filenames.append(image_dir / f) + image_filenames.append(f) image_filenames = sorted(image_filenames, key=lambda fn: int(fn.stem)) image_filenames = np.array(image_filenames) diff --git a/nerfstudio/engine/trainer.py b/nerfstudio/engine/trainer.py index 2753e4e98..25cbb2ae8 100644 --- a/nerfstudio/engine/trainer.py +++ b/nerfstudio/engine/trainer.py @@ -285,6 +285,9 @@ class Trainer: pipeline = self.pipeline.module.state_dict() # type: ignore else: pipeline = self.pipeline.state_dict() + if len(self.prev_ckpt_paths) == self.config.trainer.num_ckpt_to_save: + self.prev_ckpt_paths[0].unlink(missing_ok=True) + self.prev_ckpt_paths.pop(0) torch.save( { "step": step, @@ -295,9 +298,6 @@ class Trainer: ckpt_path, ) self.prev_ckpt_paths.append(ckpt_path) - if len(self.prev_ckpt_paths) > self.config.trainer.num_ckpt_to_save: - self.prev_ckpt_paths[0].unlink(missing_ok=True) - self.prev_ckpt_paths.pop(0) @profiler.time_function def train_iteration(self, step: int) -> Tuple[torch.Tensor, Dict[str, torch.Tensor], Dict[str, torch.Tensor]]: diff --git a/scripts/downloads/download_data.py b/scripts/downloads/download_data.py index 7a82710ad..a23fd5393 100644 --- a/scripts/downloads/download_data.py +++ b/scripts/downloads/download_data.py @@ -56,7 +56,6 @@ def grab_file_id(zip_url: str) -> str: nerfstudio_file_ids = { - "bunny": grab_file_id("https://drive.google.com/file/d/1oVytSgd1gQclF0CybJ6JdXDmaqKOx7Wg/view?usp=sharing"), "bww_entrance": grab_file_id("https://drive.google.com/file/d/1ylkRHtfB3n3IRLf2wplpfxzPTq7nES9I/view?usp=sharing"), "bww_tree": grab_file_id("https://drive.google.com/file/d/1N_OQejT0MblK1UP05KORxy25SXjKqZN1/view?usp=sharing"), "campanile": grab_file_id("https://drive.google.com/file/d/13aOfGJRRH05pOOk9ikYGTwqFc2L1xskU/view?usp=sharing"), @@ -77,11 +76,11 @@ nerfstudio_file_ids = { DatasetName = tyro.extras.literal_type_from_choices(nerfstudio_file_ids.keys()) -def download_nerfstudio(save_dir: Path, capture_name: str): - """Download specific captures from the nerfstudio dataset.""" +def download_capture_name(save_dir: Path, dataset_name: str, capture_name: str, capture_name_to_file_id: dict): + """Download specific captures a given dataset and capture name.""" - url = f"https://drive.google.com/uc?id={nerfstudio_file_ids[capture_name]}" - target_path = str(save_dir / f"nerfstudio/{capture_name}") + url = f"https://drive.google.com/uc?id={capture_name_to_file_id[capture_name]}" + target_path = str(save_dir / f"{dataset_name}/{capture_name}") os.makedirs(target_path, exist_ok=True) download_path = Path(f"{target_path}.zip") tmp_path = str(save_dir / ".temp") @@ -99,8 +98,23 @@ def download_nerfstudio(save_dir: Path, capture_name: str): os.remove(download_path) +def download_nerfstudio(save_dir: Path, capture_name: str): + """Download specific captures for the nerfstudio dataset.""" + download_capture_name(save_dir, "nerfstudio", capture_name, capture_name_to_file_id=nerfstudio_file_ids) + + +record3d_file_ids = { + "bear": grab_file_id("https://drive.google.com/file/d/1WRZohWMRj0nNlYFIEBwkddDoGPvLTzkR/view?usp=sharing"), +} + + +def download_record3d(save_dir: Path, capture_name: str): + """Download specific captures for the record3d dataset.""" + download_capture_name(save_dir, "record3d", capture_name, capture_name_to_file_id=record3d_file_ids) + + def main( - dataset: Literal["blender", "friends", "nerfstudio"], + dataset: Literal["blender", "friends", "nerfstudio", "record3d"], capture_name: Optional[DatasetName] = None, # type: ignore save_dir: Path = Path("data/"), ): @@ -137,6 +151,8 @@ def main( console.print(f"\t {capture_names}") sys.exit() download_nerfstudio(save_dir, capture_name) + if dataset == "record3d": + download_record3d(save_dir, "bear") def entrypoint():