mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-20 06:10:34 +08:00
NeRF Raymarcher
Summary: An initial NeRF diff which sets up the folder structure and implements the raymarching algorithm of NeRF. Reviewed By: nikhilaravi Differential Revision: D25623990 fbshipit-source-id: ac6b05a9b866358bd4bbf44858f06859d8a6ebd1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f4f3d403f3
commit
fba419b7f7
1
projects/nerf/tests/__init__.py
Normal file
1
projects/nerf/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
34
projects/nerf/tests/test_raymarcher.py
Normal file
34
projects/nerf/tests/test_raymarcher.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
|
||||
|
||||
import unittest
|
||||
|
||||
import torch
|
||||
from nerf.raymarcher import EmissionAbsorptionNeRFRaymarcher
|
||||
from pytorch3d.renderer import EmissionAbsorptionRaymarcher
|
||||
|
||||
|
||||
class TestRaymarcher(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
torch.manual_seed(42)
|
||||
|
||||
def test_raymarcher(self):
|
||||
"""
|
||||
Checks that the nerf raymarcher outputs are identical to the
|
||||
EmissionAbsorptionRaymarcher.
|
||||
"""
|
||||
|
||||
feat_dim = 3
|
||||
rays_densities = torch.rand(100, 10, 1)
|
||||
rays_features = torch.randn(100, 10, feat_dim)
|
||||
|
||||
out, out_nerf = [
|
||||
raymarcher(rays_densities, rays_features)
|
||||
for raymarcher in (
|
||||
EmissionAbsorptionRaymarcher(),
|
||||
EmissionAbsorptionNeRFRaymarcher(),
|
||||
)
|
||||
]
|
||||
|
||||
self.assertTrue(
|
||||
torch.allclose(out[..., :feat_dim], out_nerf[0][..., :feat_dim])
|
||||
)
|
||||
Reference in New Issue
Block a user