kwea123 / ngp_pl
- среда, 6 июля 2022 г. в 00:35:20
Instant-ngp in pytorch+cuda trained with pytorch-lightning (high quality with high speed, with only few lines of legible code)
Instant-ngp (only NeRF) in pytorch+cuda trained with pytorch-lightning (high quality with high speed). This repo aims at providing a concise pytorch interface to facilitate future research, and am grateful if you can share it (and a citation is highly appreciated)!
This implementation has strict requirements due to dependencies on other libraries, if you encounter installation problem due to hardware/software mismatch, I'm afraid there is no intention to support different platforms (you are welcomed to contribute).
Clone this repo by git clone https://github.com/kwea123/ngp_pl
Python>=3.8 (installation via anaconda is recommended, use conda create -n ngp_pl python=3.8
to create a conda environment and activate it by conda activate ngp_pl
)
Python libraries
pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu113
tinycudann
following their instruction (compilation and pytorch extension)apex
following their instructionpip install -r requirements.txt
Cuda extension: Upgrade pip
to >= 22.1 and run pip install models/csrc/
Download preprocessed datasets from NSVF.
Quickstart: python train.py --root_dir <path/to/lego> --exp_name Lego
It will train the lego scene for 20k steps (each step with 8192 rays), and perform one testing at the end. The training process should finish within about 5 minutes (saving testing image is slow, add --no_save_test
to disable). Testing PSNR will be shown at the end.
If your GPU has larger memory, you can try increasing batch_size
(and lr
) and reducing num_epochs
(e.g. --batch_size 16384 --lr 1.2e-2 --num_epochs 10
). In my experiments, this further reduces the training time by 10~25s while maintaining the same quality.
More options can be found in opt.py.
Use test.ipynb
to generate images. Lego pretrained model is available here
I compared the quality (average testing PSNR on Synthetic-NeRF
) and the inference speed (on Lego
scene) v.s. the concurrent work torch-ngp (default settings) and the paper, all trained for about 5 minutes:
Method | avg PSNR | FPS |
---|---|---|
torch-ngp | 31.46 | 18.2 |
mine | 32.38 | 36.2 |
instant-ngp paper | 33.18 | 60 |
As for quality, mine is slightly better than torch-ngp, but the result might fluctuate across different runs.
As for speed, mine is faster than torch-ngp, but is still only half fast as instant-ngp. Speed is dependent on the scene (if most of the scene is empty, speed will be faster).
More details are in the following section.
To run benchmarks, use the scripts under benchmarking
.
Followings are my results (qualitative results here):
Mic | Ficus | Chair | Hotdog | Materials | Drums | Ship | Lego | AVG | |
---|---|---|---|---|---|---|---|---|---|
PSNR | 35.23 | 33.64 | 34.78 | 36.76 | 28.77 | 25.61 | 29.57 | 34.69 | 32.38 |
FPS | 40.81 | 34.02 | 49.80 | 25.06 | 20.08 | 37.77 | 15.77 | 36.20 | 32.44 |
Wineholder | Steamtrain | Toad | Robot | Bike | Palace | Spaceship | Lifestyle | AVG | |
---|---|---|---|---|---|---|---|---|---|
PSNR | 31.06 | 35.65 | 34.49 | 36.23 | 36.99 | 36.36 | 35.48 | 33.96 | 35.03 |
FPS | 47.07 | 75.17 | 50.42 | 64.87 | 66.88 | 28.62 | 35.55 | 22.84 | 48.93 |
Ignatius | Truck | Barn | Caterpillar | Family | AVG | |
---|---|---|---|---|---|---|
PSNR | 28.90 | 28.21 | 28.92 | 26.30 | 33.77 | 29.22 |
*FPS | 10.04 | 7.99 | 16.14 | 10.91 | 6.16 | 10.25 |
*Evaluated on test-traj
*Jade | *Fountain | Character | Statues | AVG | |
---|---|---|---|---|---|
PSNR | 25.69 | 26.91 | 30.16 | 26.93 | 27.42 |
**FPS | 26.02 | 21.24 | 35.99 | 19.22 | 25.61 |
*I manually switch the background from black to white, so the number isn't directly comparable to that in the papers.
**Evaluated on test-traj