{"library":"nerfacc","title":"NerfAcc","description":"A general NeRF acceleration toolbox that provides efficient occupancy grid-based ray marching and sampling for neural radiance fields. Current version 0.5.3, with rapid development and breaking changes between minor versions.","language":"python","status":"active","last_verified":"Fri May 01","install":{"commands":["pip install nerfacc"],"cli":null},"imports":["from nerfacc import OccGridEstimator","from nerfacc import ContractionType"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import torch\nfrom nerfacc import OccGridEstimator\n\ndevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\n# Initialize an occupancy grid estimator for an unbounded scene (e.g., nerfstudio style)\nestimator = OccGridEstimator(\n    roi_aabb=[-2.0, -2.0, -2.0, 2.0, 2.0, 2.0],\n    resolution=256,\n    levels=2,\n).to(device)\n\n# Dummy occupancy update: random binary grid\nrandom_occ = torch.randint(0, 2, (estimator.binaries.shape[0], *estimator.binaries.shape[2:]), device=device, dtype=torch.bool)\nestimator.binaries = random_occ\n\n# Ray marching: generate rays and compute step sizes\nrays_o = torch.tensor([[0.0, 0.0, 0.0]], device=device)\nrays_d = torch.tensor([[1.0, 0.0, 0.0]], device=device)\nray_indices, starts, ends, hits = estimator.marching(rays_o, rays_d, near_plane=0.0, far_plane=10.0)\nprint(f\"Number of ray steps: {starts.shape[0]}\")","lang":"python","description":"Initialize a multi-level occupancy grid and perform ray marching on a dummy grid.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}