4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 10:34:29 +08:00
nerfstudio/tests/nerf/test_occupancy_grid.py
Ethan Weber fb440fedf3
Occupancy grid (#79)
* occupancy grid in progress

* visualizing occupancy grid. currently restructing field and renderer head outputs

* black and pylint. broke nerfw and semantic nerf but it's okay

* get_project_root
2022-05-17 19:09:25 -07:00

23 lines
639 B
Python

"""
Code to test the occupancy grid.
"""
import torch
from mattport.nerf.occupancy_grid import OccupancyGrid
def test_occupancy_grid():
"""For testing the occupancy grid."""
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
num_cascades = 1
resolution = 128
aabb = torch.tensor([[-1, -1, -1], [1, 1, 1]], dtype=torch.float32).to(device)
grid = OccupancyGrid(num_cascades, resolution, aabb)
grid.to(device)
density_fn = lambda x: x[..., 0:1] # xyz (..., 3) => density (...,)
grid.update_occupancy_grid(density_fn=density_fn)
if __name__ == "__main__":
test_occupancy_grid()