The optimizer uses PyTorch and CUDA extensions in a Python environment to produce trained models.
Hardware Requirements | Software Requirements |
---|---|
|
|
Our default, provided install method is based on Conda package and environment management:
SET DISTUTILS_USE_SDK=1 # Windows only
conda env create --file environment.yml
conda activate gaussian_splatting
Please note that this process assumes that you have CUDA SDK 11 installed, not 12. For modifications, see below.
Tip
Downloading packages and creating a new environment with Conda can require a significant amount of disk space. By default, Conda will use the main system hard drive. You can avoid this by specifying a different package download location and an environment on a different drive:
conda config --add pkgs_dirs <Drive>/<pkg_path>
conda env create --file environment.yml --prefix <Drive>/<env_path>/gaussian_splatting
conda activate <Drive>/<env_path>/gaussian_splatting
If you can afford the disk space, we recommend using our environment files for setting up a training environment identical to ours. If you want to make modifications, please note that major version changes might affect the results of our method. However, our (limited) experiments suggest that the codebase works just fine inside a more up-to-date environment (Python 3.8
, PyTorch 2.0.0
, CUDA 12
). Make sure to create an environment where PyTorch and its CUDA runtime version match and the installed CUDA SDK has no major version difference with PyTorch's CUDA version.
Some users experience problems building the submodules on Windows (cl.exe: File not found
or similar). Please consider the workaround for this problem from the FAQ.
To run the optimizer, simply use
python train.py -s <path to COLMAP or NeRF Synthetic dataset>
Command Line Arguments for train.py
--source_path -s |
Path to the source directory containing a COLMAP or Synthetic NeRF data set. |
--model_path -m |
Path where the trained model should be stored (output/<random> by default). |
--images -i |
Alternative subdirectory for COLMAP images (images by default). |
--eval | Add this flag to use a MipNeRF360-style training/test split for evaluation. |
--resolution -r |
Specifies resolution of the loaded images before training. If provided 1, 2, 4 or 8 , uses original, 1/2, 1/4 or 1/8 resolution, respectively. For all other values, rescales the width to the given number while maintaining image aspect. If not set and input image width exceeds 1.6K pixels, inputs are automatically rescaled to this target. |
--data_device | Specifies where to put the source image data, cuda by default, recommended to use cpu if training on large/high-resolution dataset, will reduce VRAM consumption, but slightly slow down training. Thanks to HrsPythonix. |
--white_background -w |
Add this flag to use white background instead of black (default), e.g., for evaluation of NeRF Synthetic dataset. |
--sh_degree | Order of spherical harmonics to be used (no larger than 3). 3 by default. |
--convert_SHs_python | Flag to make pipeline compute forward and backward of SHs with PyTorch instead of ours. |
--convert_cov3D_python | Flag to make pipeline compute forward and backward of the 3D covariance with PyTorch instead of ours. |
--debug | Enables debug mode if you experience erros. If the rasterizer fails, a dump file is created that you may forward to us in an issue so we can take a look. |
--debug_from | Debugging is slow. You may specify an iteration (starting from 0) after which the above debugging becomes active. |
--iterations | Number of total iterations to train for, 30_000 by default. |
--ip | IP to start GUI server on, 127.0.0.1 by default. |
--port | Port to use for GUI server, 6009 by default. |
--test_iterations | Space-separated iterations at which the training script computes L1 and PSNR over test set, 7000 30000 by default. |
--save_iterations | Space-separated iterations at which the training script saves the Gaussian model, 7000 30000 <iterations> by default. |
--checkpoint_iterations | Space-separated iterations at which to store a checkpoint for continuing later, saved in the model directory. |
--start_checkpoint | Path to a saved checkpoint to continue training from. |
--quiet | Flag to omit any text written to standard out pipe. |
--feature_lr | Spherical harmonics features learning rate, 0.0025 by default. |
--opacity_lr | Opacity learning rate, 0.05 by default. |
--scaling_lr | Scaling learning rate, 0.005 by default. |
--rotation_lr | Rotation learning rate, 0.001 by default. |
--position_lr_max_steps | Number of steps (from 0) where position learning rate goes from initial to final . 30_000 by default. |
--position_lr_init | Initial 3D position learning rate, 0.00016 by default. |
--position_lr_final | Final 3D position learning rate, 0.0000016 by default. |
--position_lr_delay_mult | Position learning rate multiplier (cf. Plenoxels), 0.01 by default. |
--densify_from_iter | Iteration where densification starts, 500 by default. |
--densify_until_iter | Iteration where densification stops, 15_000 by default. |
--densify_grad_threshold | Limit that decides if points should be densified based on 2D position gradient, 0.0002 by default. |
--densification_interval | How frequently to densify, 100 (every 100 iterations) by default. |
--opacity_reset_interval | How frequently to reset opacity, 3_000 by default. |
--lambda_dssim | Influence of SSIM on total loss from 0 to 1, 0.2 by default. |
--percent_dense | Percentage of scene extent (0--1) a point must exceed to be forcibly densified, 0.01 by default. |
Note that similar to MipNeRF360, we target images at resolutions in the 1-1.6K pixel range. For convenience, arbitrary-size inputs can be passed and will be automatically resized if their width exceeds 1600 pixels. We recommend to keep this behavior, but you may force training to use your higher-resolution images by setting -r 1
.
The MipNeRF360 scenes are hosted by the paper authors here. You can find our SfM data sets for Tanks&Temples and Deep Blending here. If you do not provide an output model directory (-m
), trained models are written to folders with randomized unique names inside the output
directory. At this point, the trained models may be viewed with the real-time viewer (see further below).
By default, the trained models use all available images in the dataset. To train them while withholding a test set for evaluation, use the --eval
flag. This way, you can render training/test sets and produce error metrics as follows:
python train.py -s <path to COLMAP or NeRF Synthetic dataset> --eval # Train with train/test split
python render.py -m <path to trained model> # Generate renderings
python metrics.py -m <path to trained model> # Compute error metrics on renderings
If you want to evaluate our pre-trained models, you will have to download the corresponding source data sets and indicate their location to render.py
with an additional --source_path/-s
flag. Note: The pre-trained models were created with the release codebase. This code base has been cleaned up and includes bugfixes, hence the metrics you get from evaluating them will differ from those in the paper.
python render.py -m <path to pre-trained model> -s <path to COLMAP dataset>
python metrics.py -m <path to pre-trained model>
Command Line Arguments for render.py
**--model_path -m |
Path to the trained model directory you want to create renderings for. |
--skip_train | Flag to skip rendering the training set. |
--skip_test | Flag to skip rendering the test set. |
--quiet | Flag to omit any text written to standard out pipe. |
The below parameters will be read automatically from the model path, based on what was used for training. However, you may override them by providing them explicitly on the command line.
--source_path -s |
Path to the source directory containing a COLMAP or Synthetic NeRF data set. |
--images -i |
Alternative subdirectory for COLMAP images (images by default). |
--eval | Add this flag to use a MipNeRF360-style training/test split for evaluation. |
--resolution -r |
Changes the resolution of the loaded images before training. If provided 1, 2, 4 or 8 , uses original, 1/2, 1/4 or 1/8 resolution, respectively. For all other values, rescales the width to the given number while maintaining image aspect. 1 by default. |
--white_background -w |
Add this flag to use white background instead of black (default), e.g., for evaluation of NeRF Synthetic dataset. |
--convert_SHs_python | Flag to make pipeline render with computed SHs from PyTorch instead of ours. |
--convert_cov3D_python | Flag to make pipeline render with computed 3D covariance from PyTorch instead of ours. |
Command Line Arguments for metrics.py
--model_paths -m |
Space-separated list of model paths for which metrics should be computed. |
We further provide the full_eval.py
script. This script specifies the routine used in our evaluation and demonstrates the use of some additional parameters, e.g., --images (-i)
to define alternative image directories within COLMAP data sets. If you have downloaded and extracted all the training data, you can run it like this:
python full_eval.py -m360 <mipnerf360 folder> -tat <tanks and temples folder> -db <deep blending folder>
In the current version, this process takes about 7h on our reference machine containing an A6000. If you want to do the full evaluation on our pre-trained models, you can specify their download location and skip training.
python full_eval.py -o <directory with pretrained models> --skip_training -m360 <mipnerf360 folder> -tat <tanks and temples folder> -db <deep blending folder>
If you want to compute the metrics on our paper's evaluation images, you can also skip rendering. In this case it is not necessary to provide the source datasets. You can compute metrics for multiple image sets at a time.
python full_eval.py -m <directory with evaluation images>/garden ... --skip_training --skip_rendering
Command Line Arguments for full_eval.py
--skip_training | Flag to skip training stage. |
--skip_rendering | Flag to skip rendering stage. |
--skip_metrics | Flag to skip metrics calculation stage. |
--output_path | Directory to put renderings and results in, ./eval by default, set to pre-trained model location if evaluating them. |
--mipnerf360 -m360 |
Path to MipNeRF360 source datasets, required if training or rendering. |
--tanksandtemples -tat |
Path to Tanks&Temples source datasets, required if training or rendering. |
--deepblending -db |
Path to Deep Blending source datasets, required if training or rendering. |