mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-19 14:23:57 +08:00
Switch to dictionary outputs
This commit is contained in:
1 parent
af74b4e95c
commit
05f2537605
6 files changed
+39
-33
No files matched your search
@@ -4,17 +4,16 @@ Field output tests
|
||||
import torch
|
||||
from torch import nn
|
||||
|
||||
from mattport.nerf.field_modules import field_heads
|
||||
from mattport.nerf.field_modules.field_heads import DensityFieldHead, FieldHead, FieldHeadNames, RGBFieldHead
|
||||
|
||||
|
||||
def test_field_output():
|
||||
"""Test render output"""
|
||||
in_dim = 6
|
||||
out_dim = 4
|
||||
field_head_name = FieldHeadNames.DENSITY
|
||||
activation = nn.ReLU()
|
||||
render_head = field_heads.FieldHead(
|
||||
in_dim=in_dim, out_dim=out_dim, field_quantity_name="rgb", activation=activation
|
||||
)
|
||||
render_head = FieldHead(in_dim=in_dim, out_dim=out_dim, field_head_name=field_head_name, activation=activation)
|
||||
assert render_head.get_out_dim() == out_dim
|
||||
|
||||
x = torch.ones((9, in_dim))
|
||||
@@ -24,7 +23,7 @@ def test_field_output():
|
||||
def test_density_output():
|
||||
"""Test rgb output"""
|
||||
in_dim = 6
|
||||
density_head = field_heads.DensityFieldHead(in_dim)
|
||||
density_head = DensityFieldHead(in_dim)
|
||||
assert density_head.get_out_dim() == 1
|
||||
|
||||
x = torch.ones((9, in_dim))
|
||||
@@ -34,8 +33,14 @@ def test_density_output():
|
||||
def test_rgb_output():
|
||||
"""Test rgb output"""
|
||||
in_dim = 6
|
||||
rgb_head = field_heads.RGBFieldHead(in_dim)
|
||||
rgb_head = RGBFieldHead(in_dim)
|
||||
assert rgb_head.get_out_dim() == 3
|
||||
|
||||
x = torch.ones((9, in_dim))
|
||||
rgb_head(x)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_field_output()
|
||||
test_density_output()
|
||||
test_rgb_output()
|
||||
@@ -2,6 +2,7 @@
|
||||
Test samplers
|
||||
"""
|
||||
import torch
|
||||
from mattport.nerf.field_modules.field_heads import FieldHeadNames
|
||||
from mattport.nerf.sampler import PDFSampler, UniformSampler
|
||||
|
||||
from mattport.structures.rays import RayBundle
|
||||
@@ -35,14 +36,14 @@ def test_pdf_sampler():
|
||||
directions = torch.ones_like(origins)
|
||||
ray_bundle = RayBundle(origins=origins, directions=directions)
|
||||
|
||||
density = torch.ones((10, num_samples, 1))
|
||||
field_outputs = {FieldHeadNames.DENSITY: torch.ones((10, num_samples, 1))}
|
||||
|
||||
uniform_sampler = UniformSampler(near_plane=near_plane, far_plane=far_plane, num_samples=num_samples)
|
||||
coarse_ray_samples = uniform_sampler(ray_bundle)
|
||||
|
||||
# Just check that it doesn't crash. Need to add some actual tests.
|
||||
pdf_sampler = PDFSampler(num_samples)
|
||||
pdf_sampler(ray_bundle, coarse_ray_samples, density, num_samples)
|
||||
pdf_sampler(ray_bundle, coarse_ray_samples, field_outputs, num_samples)
|
||||
|
||||
# TODO Tancik: Add more precise tests
|
||||
|
||||
|
||||
Reference in new issue
Block a user