{"id":15030598,"url":"https://github.com/nerfstudio-project/nerfacc","last_synced_at":"2025-05-15T14:08:54.474Z","repository":{"id":60895917,"uuid":"534105585","full_name":"nerfstudio-project/nerfacc","owner":"nerfstudio-project","description":"A General NeRF Acceleration Toolbox in PyTorch.","archived":false,"fork":false,"pushed_at":"2024-10-02T17:54:16.000Z","size":4177,"stargazers_count":1430,"open_issues_count":70,"forks_count":120,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-05-05T13:04:57.006Z","etag":null,"topics":["instant-ngp","nerf","pytorch","rendering"],"latest_commit_sha":null,"homepage":"https://www.nerfacc.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nerfstudio-project.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-08T07:46:31.000Z","updated_at":"2025-05-03T00:43:15.000Z","dependencies_parsed_at":"2023-12-06T10:44:01.280Z","dependency_job_id":"38ab5129-828a-4b5d-a245-92e4ed965eb8","html_url":"https://github.com/nerfstudio-project/nerfacc","commit_stats":{"total_commits":268,"total_committers":22,"mean_commits":"12.181818181818182","dds":0.2126865671641791,"last_synced_commit":"d8de430179ddbdbdc4f2e5ed54029e59360ffbf4"},"previous_names":["nerfstudio-project/nerfacc","kair-bair/nerfacc"],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerfstudio-project%2Fnerfacc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerfstudio-project%2Fnerfacc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerfstudio-project%2Fnerfacc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerfstudio-project%2Fnerfacc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nerfstudio-project","download_url":"https://codeload.github.com/nerfstudio-project/nerfacc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254355333,"owners_count":22057354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["instant-ngp","nerf","pytorch","rendering"],"created_at":"2024-09-24T20:13:48.500Z","updated_at":"2025-05-15T14:08:49.462Z","avatar_url":"https://github.com/nerfstudio-project.png","language":"Python","readme":"\u003cp\u003e\n  \u003c!-- pypi-strip --\u003e\n  \u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://user-images.githubusercontent.com/3310961/199083722-881a2372-62c1-4255-8521-31a95a721851.png\" /\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://user-images.githubusercontent.com/3310961/199084143-0d63eb40-3f35-48d2-a9d5-78d1d60b7d66.png\" /\u003e\n  \u003c!-- /pypi-strip --\u003e\n  \u003cimg alt=\"nerfacc logo\" src=\"https://user-images.githubusercontent.com/3310961/199084143-0d63eb40-3f35-48d2-a9d5-78d1d60b7d66.png\" width=\"350px\" /\u003e\n  \u003c!-- pypi-strip --\u003e\n  \u003c/picture\u003e\n  \u003c!-- /pypi-strip --\u003e\n\u003c/p\u003e\n\n[![Core Tests](https://github.com/nerfstudio-project/nerfacc/actions/workflows/code_checks.yml/badge.svg?branch=master)](https://github.com/nerfstudio-project/nerfacc/actions/workflows/code_checks.yml)\n[![Docs](https://github.com/nerfstudio-project/nerfacc/actions/workflows/doc.yml/badge.svg?branch=master)](https://github.com/nerfstudio-project/nerfacc/actions/workflows/doc.yml)\n[![Downloads](https://pepy.tech/badge/nerfacc)](https://pepy.tech/project/nerfacc)\n\nhttps://www.nerfacc.com/\n\n[News] 2023/04/04. If you were using `nerfacc \u003c= 0.3.5` and would like to migrate to our latest version (`nerfacc \u003e= 0.5.0`), Please check the [CHANGELOG](CHANGELOG.md) on how to migrate.\n\nNerfAcc is a PyTorch Nerf acceleration toolbox for both training and inference. It focus on\nefficient sampling in the volumetric rendering pipeline of radiance fields, which is \nuniversal and plug-and-play for most of the NeRFs.\nWith minimal modifications to the existing codebases, Nerfacc provides significant speedups \nin training various recent NeRF papers.\n**And it is pure Python interface with flexible APIs!**\n\n![Teaser](/docs/source/_static/images/teaser.jpg?raw=true)\n\n## Installation\n\n**Dependence**: Please install [Pytorch](https://pytorch.org/get-started/locally/) first.\n\nThe easist way is to install from PyPI. In this way it will build the CUDA code **on the first run** (JIT).\n```\npip install nerfacc\n```\n\nOr install from source. In this way it will build the CUDA code during installation.\n```\npip install git+https://github.com/nerfstudio-project/nerfacc.git\n```\n\nWe also provide pre-built wheels covering major combinations of Pytorch + CUDA supported by [official Pytorch](https://pytorch.org/get-started/previous-versions/).\n\n```\n# e.g., torch 1.13.0 + cu117\npip install nerfacc -f https://nerfacc-bucket.s3.us-west-2.amazonaws.com/whl/torch-1.13.0_cu117.html\n```\n\n| Windows \u0026 Linux | `cu113` | `cu115` | `cu116` | `cu117` | `cu118` |\n|-----------------|---------|---------|---------|---------|---------|\n| torch 1.11.0    | ✅      | ✅      |         |         |         |\n| torch 1.12.0    | ✅      |         | ✅      |         |         |\n| torch 1.13.0    |         |         | ✅      | ✅      |         |\n| torch 2.0.0     |         |         |         | ✅      | ✅      |\n\nFor 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.\n\n## Usage\n\nThe idea of NerfAcc is to perform efficient volumetric sampling with a computationally cheap estimator to discover surfaces.\nSo NerfAcc can work with any user-defined radiance field. To plug the NerfAcc rendering pipeline into your code and enjoy \nthe acceleration, you only need to define two functions with your radience field.\n\n- `sigma_fn`: Compute density at each sample. It will be used by the estimator\n  (e.g., `nerfacc.OccGridEstimator`, `nerfacc.PropNetEstimator`) to discover surfaces. \n- `rgb_sigma_fn`: Compute color and density at each sample. It will be used by \n  `nerfacc.rendering` to conduct differentiable volumetric rendering. This function \n  will receive gradients to update your radiance field.\n\nAn simple example is like this:\n\n``` python\nimport torch\nfrom torch import Tensor\nimport nerfacc \n\nradiance_field = ...  # network: a NeRF model\nrays_o: Tensor = ...  # ray origins. (n_rays, 3)\nrays_d: Tensor = ...  # ray normalized directions. (n_rays, 3)\noptimizer = ...       # optimizer\n\nestimator = nerfacc.OccGridEstimator(...)\n\ndef sigma_fn(\n    t_starts: Tensor, t_ends:Tensor, ray_indices: Tensor\n) -\u003e Tensor:\n    \"\"\" Define how to query density for the estimator.\"\"\"\n    t_origins = rays_o[ray_indices]  # (n_samples, 3)\n    t_dirs = rays_d[ray_indices]  # (n_samples, 3)\n    positions = t_origins + t_dirs * (t_starts + t_ends)[:, None] / 2.0\n    sigmas = radiance_field.query_density(positions) \n    return sigmas  # (n_samples,)\n\ndef rgb_sigma_fn(\n    t_starts: Tensor, t_ends: Tensor, ray_indices: Tensor\n) -\u003e Tuple[Tensor, Tensor]:\n    \"\"\" Query rgb and density values from a user-defined radiance field. \"\"\"\n    t_origins = rays_o[ray_indices]  # (n_samples, 3)\n    t_dirs = rays_d[ray_indices]  # (n_samples, 3)\n    positions = t_origins + t_dirs * (t_starts + t_ends)[:, None] / 2.0\n    rgbs, sigmas = radiance_field(positions, condition=t_dirs)  \n    return rgbs, sigmas  # (n_samples, 3), (n_samples,)\n\n# Efficient Raymarching:\n# ray_indices: (n_samples,). t_starts: (n_samples,). t_ends: (n_samples,).\nray_indices, t_starts, t_ends = estimator.sampling(\n    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, \n)\n\n# Differentiable Volumetric Rendering.\n# colors: (n_rays, 3). opacity: (n_rays, 1). depth: (n_rays, 1).\ncolor, opacity, depth, extras = nerfacc.rendering(\n    t_starts, t_ends, ray_indices, n_rays=rays_o.shape[0], rgb_sigma_fn=rgb_sigma_fn\n)\n\n# Optimize: Both the network and rays will receive gradients\noptimizer.zero_grad()\nloss = F.mse_loss(color, color_gt)\nloss.backward()\noptimizer.step()\n```\n\n## Examples: \n\nBefore 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.\n\n```bash\n# clone the repo with submodules.\ngit clone --recursive git://github.com/nerfstudio-project/nerfacc/\n```\n\n### Static NeRFs\n\nSee full benchmarking here: https://www.nerfacc.com/en/stable/examples/static.html\n\nInstant-NGP on NeRF-Synthetic dataset with better performance in 4.5 minutes.\n``` bash\n# Occupancy Grid Estimator\npython examples/train_ngp_nerf_occ.py --scene lego --data_root data/nerf_synthetic\n# Proposal Net Estimator\npython examples/train_ngp_nerf_prop.py --scene lego --data_root data/nerf_synthetic\n```\n\nInstant-NGP on Mip-NeRF 360 dataset with better performance in 5 minutes.\n``` bash\n# Occupancy Grid Estimator\npython examples/train_ngp_nerf_occ.py --scene garden --data_root data/360_v2\n# Proposal Net Estimator\npython examples/train_ngp_nerf_prop.py --scene garden --data_root data/360_v2\n```\n\nVanilla MLP NeRF on NeRF-Synthetic dataset in an hour.\n``` bash\n# Occupancy Grid Estimator\npython examples/train_mlp_nerf.py --scene lego --data_root data/nerf_synthetic\n```\n\nTensoRF on Tanks\u0026Temple and NeRF-Synthetic datasets (plugin in the official codebase).\n``` bash\ncd benchmarks/tensorf/\n# (set up the environment for that repo)\nbash script.sh nerfsyn-nerfacc-occgrid 0\nbash script.sh tt-nerfacc-occgrid 0\n```\n\n### Dynamic NeRFs\n\nSee full benchmarking here: https://www.nerfacc.com/en/stable/examples/dynamic.html\n\nT-NeRF on D-NeRF dataset in an hour.\n``` bash\n# Occupancy Grid Estimator\npython examples/train_mlp_tnerf.py --scene lego --data_root data/dnerf\n```\n\nK-Planes on D-NeRF dataset (plugin in the official codebase).\n```bash\ncd benchmarks/kplanes/\n# (set up the environment for that repo)\nbash script.sh dnerf-nerfacc-occgrid 0\n```\n\nTiNeuVox on HyperNeRF and D-NeRF datasets (plugin in the official codebase).\n```bash\ncd benchmarks/tineuvox/\n# (set up the environment for that repo)\nbash script.sh dnerf-nerfacc-occgrid 0\nbash script.sh hypernerf-nerfacc-occgrid 0\nbash script.sh hypernerf-nerfacc-propnet 0\n```\n\n### Camera Optimization NeRFs\n\nSee full benchmarking here: https://www.nerfacc.com/en/stable/examples/camera.html\n\nBARF on the NeRF-Synthetic dataset (plugin in the official codebase).\n```bash\ncd benchmarks/barf/\n# (set up the environment for that repo)\nbash script.sh nerfsyn-nerfacc-occgrid 0\n```\n\n### 3rd-Party Usages:\n\n#### Awesome Codebases.\n- [nerfstudio](https://github.com/nerfstudio-project/nerfstudio): A collaboration friendly studio for NeRFs.\n- [sdfstudio](https://autonomousvision.github.io/sdfstudio/): A unified framework for surface reconstruction.\n- [threestudio](https://github.com/threestudio-project/threestudio): A unified framework for 3D content creation.\n- [instant-nsr-pl](https://github.com/bennyguo/instant-nsr-pl): NeuS in 10 minutes.\n- [modelscope](https://github.com/modelscope/modelscope/blob/master/modelscope/models/cv/nerf_recon_acc/network/nerf.py): A collection of deep-learning algorithms.\n\n#### Awesome Papers.\n- [Representing Volumetric Videos as Dynamic MLP Maps, CVPR 2023](https://github.com/zju3dv/mlp_maps)\n- [NeRSemble: Multi-view Radiance Field Reconstruction of Human Heads, ArXiv 2023](https://tobias-kirschstein.github.io/nersemble/)\n- [HumanRF: High-Fidelity Neural Radiance Fields for Humans in Motion, ArXiv 2023](https://synthesiaresearch.github.io/humanrf/)\n\n## Common Installation Issues\n\n\u003cdetails\u003e\n    \u003csummary\u003eImportError: .../csrc.so: undefined symbol\u003c/summary\u003e\n    If you are installing a pre-built wheel, make sure the Pytorch and CUDA version matchs with the nerfacc version (nerfacc.__version__).\n\u003c/details\u003e\n\n## Citation\n\n```bibtex\n@article{li2023nerfacc,\n  title={NerfAcc: Efficient Sampling Accelerates NeRFs.},\n  author={Li, Ruilong and Gao, Hang and Tancik, Matthew and Kanazawa, Angjoo},\n  journal={arXiv preprint arXiv:2305.04966},\n  year={2023}\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerfstudio-project%2Fnerfacc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnerfstudio-project%2Fnerfacc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerfstudio-project%2Fnerfacc/lists"}