Merge branch 'master' of github.com:ethanweber/mattport into eng/distributed_training

This commit is contained in:
evonneng committed 2022-04-15 22:22:07 +00:00
commit b2220fef28
19 files changed
+112 -48

No files matched your search

@@ -3,7 +3,7 @@ Encoding Tests
"""
import pytest
import torch
from mattport.nerf.modules import encoding
from mattport.nerf.field_modules import encoding
def test_scaling_and_offset():
@@ -0,0 +1,56 @@
"""
Render Head Tests
"""
import pytest
import torch
from torch import nn
from mattport.nerf.field_modules import field_outputs
def test_field_output():
"""Test rgb render head"""
in_dim = 6
out_dim = 4
activation = nn.ReLU()
render_head = field_outputs.FieldOutput(in_dim=in_dim, out_dim=out_dim, activation=activation)
assert render_head.get_out_dim() == out_dim
x = torch.ones((9, in_dim))
with pytest.raises(SystemError):
render_head(x)
render_head.build_nn_modules()
y = render_head(x)
assert y.shape[-1] == out_dim
def test_density_head():
"""Test rgb output"""
in_dim = 6
density_head = field_outputs.DensityFieldOutput(in_dim)
assert density_head.get_out_dim() == 1
x = torch.ones((9, in_dim))
with pytest.raises(SystemError):
density_head(x)
density_head.build_nn_modules()
y = density_head(x)
assert y.shape[-1] == 1
def test_rgb_head():
"""Test rgb output"""
in_dim = 6
rgb_head = field_outputs.RGBFieldOutput(in_dim)
assert rgb_head.get_out_dim() == 3
x = torch.ones((9, in_dim))
with pytest.raises(SystemError):
rgb_head(x)
rgb_head.build_nn_modules()
y = rgb_head(x)
assert y.shape[-1] == 3
File renamed without changes.
@@ -1,5 +1,7 @@
"""
Tests of graph construction
"""
import numpy as np
import pytest
from hydra import compose, initialize
from omegaconf import open_dict
@@ -28,7 +30,7 @@ def instantiate_graph(config_name: str) -> Graph:
def test_graph_init():
"""test modules dictionary is instantiated properly"""
"""test field modules dictionary is instantiated properly"""
test_graph, _ = instantiate_graph("test_basic_graph")
assert test_graph.modules is not None
assert type(test_graph.modules["encoder_0"]).__name__ == "ScalingAndOffset"
@@ -37,7 +39,7 @@ def test_graph_init():
def test_input_dimension():
"""test module input dimension calculation"""
"""test field module input dimension calculation"""
test_graph, _ = instantiate_graph("test_repeat_graph")
assert test_graph.modules["mlp_0"].in_dim == 16
assert test_graph.modules["mlp_1"].in_dim == 1
-9
View File
@@ -1,9 +0,0 @@
import pytest
def test_positional_encoding():
assert True
def test_lower_case():
assert "MATTPORT".lower() == "mattport"
+1 -1
View File
@@ -4,7 +4,7 @@ Test ray generation.
import torch
from mattport.nerf.dataset.blender_dataset import load_blender_data
from mattport.nerf.modules.ray_generator import RayGenerator
from mattport.nerf.field_modules.ray_generator import RayGenerator
from mattport.structures.rays import RayBundle
from mattport.utils.io import get_absolute_path