


https://www.nerfacc.com/
[뉴스] 2023/04/04. nerfacc <= 0.3.5 사용하고 있고 최신 버전 ( nerfacc >= 0.5.0 )으로 마이그레이션하려면 마이그레이션 방법에 대한 Changelog를 확인하십시오.
NERFACC는 교육 및 추론을위한 Pytorch NERF Acceleration Toolbox입니다. Radiance 필드의 체적 렌더링 파이프 라인의 효율적인 샘플링에 중점을 둡니다. 기존 코드베이스를 최소화하면서 NERFACC는 다양한 최근 NERF 용지를 훈련시키는 데 상당한 속도를 제공합니다. 그리고 유연한 API가있는 순수한 파이썬 인터페이스입니다!

의존성 : 먼저 Pytorch를 설치하십시오.
쉬운 방법은 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는 모든 사용자 정의 Radiance 필드에서 작업 할 수 있습니다. NERFACC 렌더링 파이프 라인을 코드에 연결하고 가속도를 즐기려면 방사형 필드로 두 가지 기능 만 정의하면됩니다.
sigma_fn : 각 샘플에서 밀도를 계산합니다. 표면을 발견하기 위해 추정기 (예 : nerfacc.OccGridEstimator , nerfacc.PropNetEstimator )가 사용합니다.rgb_sigma_fn : 각 샘플에서 색상과 밀도를 계산합니다. nerfacc.rendering 에서 사용하여 차별화 가능한 체적 렌더링을 수행하기 위해 사용됩니다. 이 기능은 Radiance 필드를 업데이트하기위한 그라디언트를받습니다.간단한 예는 다음과 같습니다.
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-synthetic 데이터 세트의 Instant-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 데이터 세트의 Instant-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-synthetic 데이터 세트의 바닐라 MLP NERF.
# Occupancy Grid Estimator
python examples/train_mlp_nerf.py --scene lego --data_root data/nerf_synthetic탱크 및 사원 및 Nerf-synthetic 데이터 세트의 Tensorf (공식 코드베이스의 플러그인).
cd benchmarks/tensorf/
# (set up the environment for that repo)
bash script.sh nerfsyn-nerfacc-occgrid 0
bash script.sh tt-nerfacc-occgrid 0여기에서 전체 벤치마킹을 참조하십시오 : https://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- 계획 (공식 코드베이스의 플러그인).
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 0여기에서 전체 벤치마킹을 참조하십시오 : https://www.nerfacc.com/en/stable/examples/camera.html
NERF-Synthetic 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 }
}