Home

Awesome

Instant Neural Surface Reconstruction

This repository contains a concise and extensible implementation of NeRF and NeuS for neural surface reconstruction based on Instant-NGP and the Pytorch-Lightning framework. Training on a NeRF-Synthetic scene takes ~5min for NeRF and ~10min for NeuS on a single RTX3090.

NeRF in 5minNeuS in 10 min
Renderingrendering-nerfrendering-neus
Meshmesh-nerfmesh-neus

Features

This repository aims to provide a highly efficient while customizable boilerplate for research projects based on NeRF or NeuS.

Please subscribe to #26 for our latest findings on quality improvements!

News

🔥🔥🔥 Check out my new project on 3D content generation: https://github.com/threestudio-project/threestudio 🔥🔥🔥

Requirements

Note:

Environments

Run

Training on NeRF-Synthetic

Download the NeRF-Synthetic data here and put it under load/. The file structure should be like load/nerf_synthetic/lego.

Run the launch script with --train, specifying the config file, the GPU(s) to be used (GPU 0 will be used by default), and the scene name:

# train NeRF
python launch.py --config configs/nerf-blender.yaml --gpu 0 --train dataset.scene=lego tag=example

# train NeuS with mask
python launch.py --config configs/neus-blender.yaml --gpu 0 --train dataset.scene=lego tag=example
# train NeuS without mask
python launch.py --config configs/neus-blender.yaml --gpu 0 --train dataset.scene=lego tag=example system.loss.lambda_mask=0.0

The code snapshots, checkpoints and experiment outputs are saved to exp/[name]/[tag]@[timestamp], and tensorboard logs can be found at runs/[name]/[tag]@[timestamp]. You can change any configuration in the YAML file by specifying arguments without --, for example:

python launch.py --config configs/nerf-blender.yaml --gpu 0 --train dataset.scene=lego tag=iter50k seed=0 trainer.max_steps=50000

Training on DTU

Download preprocessed DTU data provided by NeuS or IDR. In the provided config files we assume using NeuS DTU data. If you are using IDR DTU data, please set dataset.cameras_file=cameras.npz. You may also need to adjust dataset.root_dir to point to your downloaded data location.

# train NeuS on DTU without mask
python launch.py --config configs/neus-dtu.yaml --gpu 0 --train
# train NeuS on DTU with mask
python launch.py --config configs/neus-dtu-wmask.yaml --gpu 0 --train
# train NeuS on DTU with mask using tricks from Neuralangelo (experimental)
python launch.py --config configs/neuralangelo-dtu-wmask.yaml --gpu 0 --train

Notes:

Training on Custom COLMAP Data

To get COLMAP data from custom images, you should have COLMAP installed (see here for installation instructions). Then put your images in the images/ folder, and run scripts/imgs2poses.py specifying the path containing the images/ folder. For example:

python scripts/imgs2poses.py ./load/bmvs_dog # images are in ./load/bmvs_dog/images

Existing data following this file structure also works as long as images are store in images/ and there is a sparse/ folder for the COLMAP output, for example the data provided by MipNeRF 360. An optional masks/ folder could be provided for object mask supervision. To train on COLMAP data, please refer to the example config files config/*-colmap.yaml. Some notes:

Testing

The training procedure are by default followed by testing, which computes metrics on test data, generates animations and exports the geometry as triangular meshes. If you want to do testing alone, just resume the pretrained model and replace --train with --test, for example:

python launch.py --config path/to/your/exp/config/parsed.yaml --resume path/to/your/exp/ckpt/epoch=0-step=20000.ckpt --gpu 0 --test

Benchmarks

All experiments are conducted on a single NVIDIA RTX3090.

PSNRChairDrumsFicusHotdogLegoMaterialsMicShipAvg.
NeRF Paper33.0025.0130.1336.1832.5429.6232.9128.6531.01
NeRF Ours (20k)34.8026.0433.8937.4235.3329.4635.2231.1732.92
NeuS Ours (20k, with masks)34.0425.2632.4735.9433.7827.6733.4329.5031.51
Training Time (mm:ss)ChairDrumsFicusHotdogLegoMaterialsMicShipAvg.
NeRF Ours (20k)04:3404:3504:1804:4604:3904:3504:2605:4104:42
NeuS Ours (20k, with masks)11:2510:3409:5112:1111:3711:4609:5916:2511:44

TODO

Related Projects

Citation

If you find this codebase useful, please consider citing:

@misc{instant-nsr-pl,
    Author = {Yuan-Chen Guo},
    Year = {2022},
    Note = {https://github.com/bennyguo/instant-nsr-pl},
    Title = {Instant Neural Surface Reconstruction}
}