


https://www.nerfacc.com/
[ニュース] 2023/04/04。 nerfacc <= 0.3.5を使用していて、最新バージョン( nerfacc >= 0.5.0 )に移行したい場合は、移行方法についてChangelogを確認してください。
NERFACCは、トレーニングと推論の両方のためのPytorch nerf Accelerationツールボックスです。これは、ほとんどのnerfsの普遍的でプラグアンドプレイである放射磁場の体積レンダリングパイプラインの効率的なサンプリングに焦点を当てています。 NERFACCは、既存のコードベースを最小限に抑えることで、最近のさまざまなNERF論文のトレーニングにおいて重要なスピードアップを提供します。そして、柔軟なAPIを備えた純粋なPythonインターフェイスです!

依存関係:最初にPytorchをインストールしてください。
EASISTの方法は、Pypiからインストールすることです。このようにして、最初の実行(JIT)でCUDAコードを構築します。
pip install nerfacc
またはソースからインストールします。このようにして、インストール中にCUDAコードを構築します。
pip install git+https://github.com/nerfstudio-project/nerfacc.git
また、公式のPytorchがサポートするPytorch + Cudaの主要な組み合わせをカバーする事前に構築されたホイールを提供しています。
# e.g., torch 1.13.0 + cu117
pip install nerfacc -f https://nerfacc-bucket.s3.us-west-2.amazonaws.com/whl/torch-1.13.0_cu117.html
| Windows&Linux | cu113 | cu115 | cu116 | cu117 | cu118 |
|---|---|---|---|---|---|
| トーチ1.11.0 | ✅ | ✅ | |||
| トーチ1.12.0 | ✅ | ✅ | |||
| トーチ1.13.0 | ✅ | ✅ | |||
| トーチ2.0.0 | ✅ | ✅ |
NERFACCの以前のバージョンについては、サポートされている事前に構築されたホイールでここで確認してください。
NERFACCのアイデアは、計算的に安価な推定器で効率的な体積サンプリングを実行して表面を発見することです。したがって、NERFACCは、ユーザー定義の輝きフィールドで動作できます。 NERFACCレンダリングパイプラインをコードに接続し、加速を楽しむには、ラディエンスフィールドで2つの機能を定義するだけです。
sigma_fn :各サンプルで密度を計算します。表面を発見するために、推定器( nerfacc.OccGridEstimator 、 nerfacc.PropNetEstimator )によって使用されます。rgb_sigma_fn :各サンプルで色と密度を計算します。 nerfacc.renderingによって使用され、微分可能な体積レンダリングを実施します。この関数は、輝きフィールドを更新するための勾配を受け取ります。簡単な例は次のようなものです:
import torch
from torch import Tensor
import nerfacc
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 (...)
def sigma_fn (
t_starts : Tensor , t_ends : Tensor , ray_indices : Tensor
) -> Tensor :
""" Define how to query density for the estimator."""
t_origins = rays_o [ ray_indices ] # (n_samples, 3)
t_dirs = rays_d [ ray_indices ] # (n_samples, 3)
positions = t_origins + t_dirs * ( t_starts + t_ends )[:, None ] / 2.0
sigmas = radiance_field . query_density ( positions )
return sigmas # (n_samples,)
def rgb_sigma_fn (
t_starts : Tensor , t_ends : Tensor , ray_indices : Tensor
) -> Tuple [ Tensor , Tensor ]:
""" Query rgb and density values from a user-defined radiance field. """
t_origins = rays_o [ ray_indices ] # (n_samples, 3)
t_dirs = rays_d [ ray_indices ] # (n_samples, 3)
positions = t_origins + t_dirs * ( t_starts + t_ends )[:, None ] / 2.0
rgbs , sigmas = radiance_field ( positions , condition = t_dirs )
return rgbs , sigmas # (n_samples, 3), (n_samples,)
# Efficient Raymarching:
# ray_indices: (n_samples,). t_starts: (n_samples,). t_ends: (n_samples,).
ray_indices , t_starts , t_ends = estimator . sampling (
rays_o , rays_d , sigma_fn = sigma_fn , near_plane = 0.2 , far_plane = 1.0 , early_stop_eps = 1e-4 , alpha_thre = 1e-2 ,
)
# Differentiable Volumetric Rendering.
# colors: (n_rays, 3). opacity: (n_rays, 1). depth: (n_rays, 1).
color , opacity , depth , extras = nerfacc . rendering (
t_starts , t_ends , ray_indices , n_rays = rays_o . shape [ 0 ], rgb_sigma_fn = rgb_sigma_fn
)
# Optimize: Both the network and rays will receive gradients
optimizer . zero_grad ()
loss = F . mse_loss ( color , color_gt )
loss . backward ()
optimizer . step ()これらのサンプルスクリプトを実行する前に、データセットが必要かについてスクリプトを確認し、最初にデータセットをダウンロードしてください。 --data_rootを使用してパスを指定できます。
# clone the repo with submodules.
git clone --recursive git://github.com/nerfstudio-project/nerfacc/https://www.nerfacc.com/en/stable/examples/static.htmlを参照してください
4.5分でパフォーマンスが向上し、NERF合成データセットのインスタントNGP。
# Occupancy Grid Estimator
python examples/train_ngp_nerf_occ.py --scene lego --data_root data/nerf_synthetic
# Proposal Net Estimator
python examples/train_ngp_nerf_prop.py --scene lego --data_root data/nerf_synthetic5分でパフォーマンスが向上し、MIP-NERF 360データセットのインスタントNGP。
# Occupancy Grid Estimator
python examples/train_ngp_nerf_occ.py --scene garden --data_root data/360_v2
# Proposal Net Estimator
python examples/train_ngp_nerf_prop.py --scene garden --data_root data/360_v21時間でnerf-sentheticデータセットのバニラmlp nerf。
# Occupancy Grid Estimator
python examples/train_mlp_nerf.py --scene lego --data_root data/nerf_syntheticTanks&Templeおよびnerf-sentheticデータセットのTensorf(公式コードベースのプラグイン)。
cd benchmarks/tensorf/
# (set up the environment for that repo)
bash script.sh nerfsyn-nerfacc-occgrid 0
bash script.sh tt-nerfacc-occgrid 0https://www.nerfacc.com/en/stable/examples/dynamic.htmlを参照してください
1時間でd-nerfデータセットのt-nerf。
# Occupancy Grid Estimator
python examples/train_mlp_tnerf.py --scene lego --data_root data/dnerfd-nerfデータセット上のk-planes(公式コードベースのプラグイン)。
cd benchmarks/kplanes/
# (set up the environment for that repo)
bash script.sh dnerf-nerfacc-occgrid 0Hypernerfおよびd-nerfデータセットのTineuvox(公式コードベースのプラグイン)。
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 0https://www.nerfacc.com/en/stable/examples/camera.htmlを参照してください
Nerf-senthetic Datasetのbarf(公式コードベースのプラグイン)。
cd benchmarks/barf/
# (set up the environment for that repo)
bash script.sh nerfsyn-nerfacc-occgrid 0 @article { li2023nerfacc ,
title = { NerfAcc: Efficient Sampling Accelerates NeRFs. } ,
author = { Li, Ruilong and Gao, Hang and Tancik, Matthew and Kanazawa, Angjoo } ,
journal = { arXiv preprint arXiv:2305.04966 } ,
year = { 2023 }
}