[News] 2023/04/04. If you were using `nerfacc <= 0.3.5` and would like to migrate to our latest version (`nerfacc >= 0.5.0`), Please check the [CHANGELOG](CHANGELOG.md) on how to migrate.
We also provide pre-built wheels covering major combinations of Pytorch + CUDA supported by [official Pytorch](https://pytorch.org/get-started/previous-versions/).
For previous version of nerfacc, please check [here](https://nerfacc-bucket.s3.us-west-2.amazonaws.com/whl/index.html) on the supported pre-built wheels.
## Usage
The idea of NerfAcc is to perform efficient volumetric sampling with a computationally cheap estimator to discover surfaces.
So NerfAcc can work with any user-defined radiance field. To plug the NerfAcc rendering pipeline into your code and enjoy
the acceleration, you only need to define two functions with your radience field.
-`sigma_fn`: Compute density at each sample. It will be used by the estimator
(e.g., `nerfacc.OccGridEstimator`, `nerfacc.PropNetEstimator`) to discover surfaces.
-`rgb_sigma_fn`: Compute color and density at each sample. It will be used by
`nerfacc.rendering` to conduct differentiable volumetric rendering. This function
will receive gradients to update your radiance field.
An simple example is like this:
``` python
importtorch
fromtorchimportTensor
importnerfacc
radiance_field=...# network: a NeRF model
rays_o:Tensor=...# ray origins. (n_rays, 3)
rays_d:Tensor=...# ray normalized directions. (n_rays, 3)
optimizer=...# optimizer
estimator=nerfacc.OccGridEstimator(...)
defsigma_fn(
t_starts:Tensor,t_ends:Tensor,ray_indices:Tensor
)->Tensor:
""" Define how to query density for the estimator."""
Before running those example scripts, please check the script about which dataset is needed, and download the dataset first. You could use `--data_root` to specify the path.
K-Planes on D-NeRF dataset (plugin in the official codebase).
```bash
cd benchmarks/kplanes/
# (set up the environment for that repo)
bash script.sh dnerf-nerfacc-occgrid 0
python3
Python 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nerfacc
>>> nerfacc.__version__
'0.5.3'
>>>
```
版本号与官方版本同步,查询该软件的版本号;
TiNeuVox on HyperNeRF and D-NeRF datasets (plugin in the official codebase).
```bash
cd benchmarks/tineuvox/
# (set up the environment for that repo)
bash script.sh dnerf-nerfacc-occgrid 0
bash script.sh hypernerf-nerfacc-occgrid 0
bash script.sh hypernerf-nerfacc-propnet 0
```
## Known Issue
- 无
### Camera Optimization NeRFs
See full benchmarking here: https://www.nerfacc.com/en/stable/examples/camera.html
BARF on the NeRF-Synthetic dataset (plugin in the official codebase).
```bash
cd benchmarks/barf/
# (set up the environment for that repo)
bash script.sh nerfsyn-nerfacc-occgrid 0
```
### 3rd-Party Usages:
#### Awesome Codebases.
-[nerfstudio](https://github.com/nerfstudio-project/nerfstudio): A collaboration friendly studio for NeRFs.
-[sdfstudio](https://autonomousvision.github.io/sdfstudio/): A unified framework for surface reconstruction.
-[threestudio](https://github.com/threestudio-project/threestudio): A unified framework for 3D content creation.
-[instant-nsr-pl](https://github.com/bennyguo/instant-nsr-pl): NeuS in 10 minutes.
-[modelscope](https://github.com/modelscope/modelscope/blob/master/modelscope/models/cv/nerf_recon_acc/network/nerf.py): A collection of deep-learning algorithms.
#### Awesome Papers.
-[Representing Volumetric Videos as Dynamic MLP Maps, CVPR 2023](https://github.com/zju3dv/mlp_maps)
-[NeRSemble: Multi-view Radiance Field Reconstruction of Human Heads, ArXiv 2023](https://tobias-kirschstein.github.io/nersemble/)
-[HumanRF: High-Fidelity Neural Radiance Fields for Humans in Motion, ArXiv 2023](https://synthesiaresearch.github.io/humanrf/)
[News] 2023/04/04. If you were using `nerfacc <= 0.3.5` and would like to migrate to our latest version (`nerfacc >= 0.5.0`), Please check the [CHANGELOG](CHANGELOG.md) on how to migrate.
NerfAcc is a PyTorch Nerf acceleration toolbox for both training and inference. It focus on
efficient sampling in the volumetric rendering pipeline of radiance fields, which is
universal and plug-and-play for most of the NeRFs.
With minimal modifications to the existing codebases, Nerfacc provides significant speedups
in training various recent NeRF papers.
**And it is pure Python interface with flexible APIs!**
We also provide pre-built wheels covering major combinations of Pytorch + CUDA supported by [official Pytorch](https://pytorch.org/get-started/previous-versions/).
For previous version of nerfacc, please check [here](https://nerfacc-bucket.s3.us-west-2.amazonaws.com/whl/index.html) on the supported pre-built wheels.
## Usage
The idea of NerfAcc is to perform efficient volumetric sampling with a computationally cheap estimator to discover surfaces.
So NerfAcc can work with any user-defined radiance field. To plug the NerfAcc rendering pipeline into your code and enjoy
the acceleration, you only need to define two functions with your radience field.
-`sigma_fn`: Compute density at each sample. It will be used by the estimator
(e.g., `nerfacc.OccGridEstimator`, `nerfacc.PropNetEstimator`) to discover surfaces.
-`rgb_sigma_fn`: Compute color and density at each sample. It will be used by
`nerfacc.rendering` to conduct differentiable volumetric rendering. This function
will receive gradients to update your radiance field.
An simple example is like this:
``` python
importtorch
fromtorchimportTensor
importnerfacc
radiance_field=...# network: a NeRF model
rays_o:Tensor=...# ray origins. (n_rays, 3)
rays_d:Tensor=...# ray normalized directions. (n_rays, 3)
optimizer=...# optimizer
estimator=nerfacc.OccGridEstimator(...)
defsigma_fn(
t_starts:Tensor,t_ends:Tensor,ray_indices:Tensor
)->Tensor:
""" Define how to query density for the estimator."""
# Optimize: Both the network and rays will receive gradients
optimizer.zero_grad()
loss=F.mse_loss(color,color_gt)
loss.backward()
optimizer.step()
```
## Examples:
Before running those example scripts, please check the script about which dataset is needed, and download the dataset first. You could use `--data_root` to specify the path.
K-Planes on D-NeRF dataset (plugin in the official codebase).
```bash
cd benchmarks/kplanes/
# (set up the environment for that repo)
bash script.sh dnerf-nerfacc-occgrid 0
```
TiNeuVox on HyperNeRF and D-NeRF datasets (plugin in the official codebase).
```bash
cd benchmarks/tineuvox/
# (set up the environment for that repo)
bash script.sh dnerf-nerfacc-occgrid 0
bash script.sh hypernerf-nerfacc-occgrid 0
bash script.sh hypernerf-nerfacc-propnet 0
```
### Camera Optimization NeRFs
See full benchmarking here: https://www.nerfacc.com/en/stable/examples/camera.html
BARF on the NeRF-Synthetic dataset (plugin in the official codebase).
```bash
cd benchmarks/barf/
# (set up the environment for that repo)
bash script.sh nerfsyn-nerfacc-occgrid 0
```
### 3rd-Party Usages:
#### Awesome Codebases.
-[nerfstudio](https://github.com/nerfstudio-project/nerfstudio): A collaboration friendly studio for NeRFs.
-[sdfstudio](https://autonomousvision.github.io/sdfstudio/): A unified framework for surface reconstruction.
-[threestudio](https://github.com/threestudio-project/threestudio): A unified framework for 3D content creation.
-[instant-nsr-pl](https://github.com/bennyguo/instant-nsr-pl): NeuS in 10 minutes.
-[modelscope](https://github.com/modelscope/modelscope/blob/master/modelscope/models/cv/nerf_recon_acc/network/nerf.py): A collection of deep-learning algorithms.
#### Awesome Papers.
-[Representing Volumetric Videos as Dynamic MLP Maps, CVPR 2023](https://github.com/zju3dv/mlp_maps)
-[NeRSemble: Multi-view Radiance Field Reconstruction of Human Heads, ArXiv 2023](https://tobias-kirschstein.github.io/nersemble/)
-[HumanRF: High-Fidelity Neural Radiance Fields for Humans in Motion, ArXiv 2023](https://synthesiaresearch.github.io/humanrf/)