test_all.py 1.19 KB
Newer Older
Ruilong Li(李瑞龙)'s avatar
Ruilong Li(李瑞龙) committed
1
2
3
import torch
import tqdm

4
from nerfacc import volumetric_rendering_pipeline
Ruilong Li(李瑞龙)'s avatar
Ruilong Li(李瑞龙) committed
5
6
7
8

device = "cuda:0"


9
def sigma_fn(frustum_starts, frustum_ends, ray_indices):
Ruilong Li(李瑞龙)'s avatar
Ruilong Li(李瑞龙) committed
10
11
12
    return torch.rand_like(frustum_ends[:, :1])


13
14
15
16
def rgb_sigma_fn(frustum_starts, frustum_ends, ray_indices):
    return torch.rand((frustum_ends.shape[0], 3), device=device), torch.rand_like(
        frustum_ends
    )
Ruilong Li(李瑞龙)'s avatar
Ruilong Li(李瑞龙) committed
17
18
19
20
21
22
23
24
25
26
27
28


def test_rendering():
    scene_aabb = torch.tensor([0, 0, 0, 1, 1, 1], device=device).float()
    scene_resolution = [128, 128, 128]
    scene_occ_binary = torch.ones((128 * 128 * 128), device=device).bool()
    rays_o = torch.rand((10000, 3), device=device)
    rays_d = torch.randn((10000, 3), device=device)
    rays_d = rays_d / rays_d.norm(dim=-1, keepdim=True)
    render_bkgd = torch.ones(3, device=device)

    for step in tqdm.tqdm(range(1000)):
29
        volumetric_rendering_pipeline(
Ruilong Li(李瑞龙)'s avatar
Ruilong Li(李瑞龙) committed
30
            sigma_fn,
31
            rgb_sigma_fn,
Ruilong Li(李瑞龙)'s avatar
Ruilong Li(李瑞龙) committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
            rays_o,
            rays_d,
            scene_aabb,
            scene_resolution,
            scene_occ_binary,
            render_bkgd,
            render_step_size=1e-3,
            near_plane=0.0,
            stratified=False,
        )


if __name__ == "__main__":
    test_rendering()