diff --git a/docs/conf.py b/docs/conf.py index d4ebac9f8..67be8f1de 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,6 +33,7 @@ release = "0.0.0" # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ + "sphinxarg.ext", "sphinx.ext.duration", "sphinx.ext.doctest", "sphinx.ext.autodoc", diff --git a/docs/index.rst b/docs/index.rst index 12ad7710a..e03358ca3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -57,8 +57,9 @@ Contents :hidden: :caption: Reference - Contributing + reference/cli/index reference/api/index + Contributing diff --git a/docs/reference/cli/index.rst b/docs/reference/cli/index.rst new file mode 100644 index 000000000..321fa207d --- /dev/null +++ b/docs/reference/cli/index.rst @@ -0,0 +1,8 @@ +.. _cli: + +CLI +============ + +.. toctree:: + + ns_process_data \ No newline at end of file diff --git a/docs/reference/cli/ns_process_data.md b/docs/reference/cli/ns_process_data.md new file mode 100644 index 000000000..c2d09728e --- /dev/null +++ b/docs/reference/cli/ns_process_data.md @@ -0,0 +1,14 @@ +# ns-process-data + +:::{admonition} Note +:class: warning +Make sure to have [COLMAP](https://colmap.github.io) and [FFmpeg](https://ffmpeg.org/download.html) installed. +::: + +```{eval-rst} +.. argparse:: + :module: scripts.process_data + :func: get_parser_fn + :prog: ns-process-data + :nodefault: +``` diff --git a/docs/tutorials/data/creating_dataset.md b/docs/tutorials/data/creating_dataset.md index 248f3ea22..57133e743 100644 --- a/docs/tutorials/data/creating_dataset.md +++ b/docs/tutorials/data/creating_dataset.md @@ -9,10 +9,10 @@ To assist running on custom data we have a script that will process a video or f To process your data run: ```bash -python scripts/process_data.py --data FOLDER_OR_VIDEO --output-dir PROCESSED_DATA_DIR +ns-process-data --data FOLDER_OR_VIDEO --output-dir PROCESSED_DATA_DIR ``` -If your data was captured with a fisheye camera add `--camera-type fisheye`. +A full set of arguments can be found {doc}`here`. :::{admonition} Tip :class: info diff --git a/docs/tutorials/data/index.rst b/docs/tutorials/data/index.rst index d5e15e0af..7d1d6c888 100644 --- a/docs/tutorials/data/index.rst +++ b/docs/tutorials/data/index.rst @@ -1,8 +1,6 @@ Data Setup ---------- -# TODO: high level summary - .. toctree:: :maxdepth: 1 diff --git a/nerfstudio/configs/model_configs.py b/nerfstudio/configs/model_configs.py index f613709a1..e27e094f8 100644 --- a/nerfstudio/configs/model_configs.py +++ b/nerfstudio/configs/model_configs.py @@ -42,6 +42,17 @@ from nerfstudio.pipelines.base_pipeline import VanillaPipelineConfig from nerfstudio.pipelines.dynamic_batch import DynamicBatchPipelineConfig model_configs: Dict[str, Config] = {} +descriptions = { + "nerfacto": "[bold green]Recommended[/bold green] Real-time model tuned for real captures. " + + "This model will be continually updated.", + "instant-ngp": "Implementation of Instant-NGP. Recommended real-time model for bounded synthetic data.", + "mipnerf-360": "High quality model for unbounded 360 degree scenes. [red]*slow*", + "mipnerf": "High quality model for bounded scenes. [red]*slow*", + "nerfw": "Model designed to handle inconsistent appearance between images. [red]*slow*", + "semantic-nerf": "Model that predicts dense semantic segmentations. [red]*slow*", + "vanilla-nerf": "Original NeRF model. [red]*slow*", + "tensorf": "Fast model designed for bounded scenes.", +} model_configs["nerfacto"] = Config( method_name="nerfacto", @@ -205,7 +216,9 @@ model_configs["tensorf"] = Config( ) -AnnotatedBaseConfigUnion = dcargs.extras.subcommand_type_from_defaults(model_configs) +AnnotatedBaseConfigUnion = dcargs.extras.subcommand_type_from_defaults( + defaults=model_configs, descriptions=descriptions +) """Union[] type over config types, annotated with default instances for use with dcargs.cli(). Allows the user to pick between one of several base configurations, and then override values in it.""" diff --git a/pyproject.toml b/pyproject.toml index 338fc492a..f1af8845b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "aiortc==1.3.2", "appdirs>=1.4", "av==9.2.0", - "dcargs>=0.3.11", + "dcargs>=0.3.14", "gdown==4.5.1", "ninja==1.10.2.3", "functorch==0.2.1", @@ -68,6 +68,7 @@ docs = [ "nbformat==5.4.0", "sphinx==4.5.0", "sphinxemoji==0.2.0", + "sphinx-argparse==0.3.1", "sphinx-copybutton==0.5.0", "sphinx-design==0.2.0" ] diff --git a/scripts/process_data.py b/scripts/process_data.py index 66bb774be..4e545ce37 100755 --- a/scripts/process_data.py +++ b/scripts/process_data.py @@ -97,7 +97,7 @@ def get_vocab_tree() -> Path: return vocab_tree_filename -def run_command(cmd, verbose=False) -> Optional[str]: +def run_command(cmd: str, verbose=False) -> Optional[str]: """Runs a command and returns the output. Args: @@ -165,7 +165,7 @@ def convert_video_to_images( return num_frames, len(list(image_dir.glob("*.png"))) -def copy_images(data, image_dir, verbose) -> int: +def copy_images(data: Path, image_dir: Path, verbose) -> int: """Copy images from a directory to a new directory. Args: @@ -176,11 +176,15 @@ def copy_images(data, image_dir, verbose) -> int: The number of images copied. """ image_paths = sorted(data.glob("*")) - for i, image_path in enumerate(image_paths): - i = i + 1 # 1-indexed + idx = 0 + # Images should be 1-indexed for the rest of the pipeline. + for image_path in image_paths: + if image_path.name.startswith("."): + continue + idx += 1 if verbose: - CONSOLE.log(f"Copying image {i + 1} of {len(image_paths)}...") - shutil.copy(image_path, image_dir / f"frame_{i:05d}{image_path.suffix}") + CONSOLE.log(f"Copying image {idx} of {len(image_paths)}...") + shutil.copy(image_path, image_dir / f"frame_{idx:05d}{image_path.suffix}") return len(image_paths) @@ -383,10 +387,11 @@ def main( """Process images or videos into a nerfstudio dataset. This script does the following: - 1) Converts the video into images (if video is provided). - 2) Scales images to a specified size. - 3) Calculates and stores the sharpness of each image. - 4) Calculates the camera poses for each image using `COLMAP `_. + + 1. Converts the video into images (if video is provided). + 2. Scales images to a specified size. + 3. Calculates and stores the sharpness of each image. + 4. Calculates the camera poses for each image using `COLMAP `_. Args: @@ -403,8 +408,6 @@ def main( verbose: If True, print extra logging. """ - print(data) - check_ffmpeg_installed() check_colmap_installed() @@ -491,3 +494,6 @@ def entrypoint(): if __name__ == "__main__": entrypoint() + +# For sphinx docs +get_parser_fn = lambda: dcargs.extras.get_parser(main) # noqa