4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-10 18:17:31 +08:00
nerfstudio/tests/field_components/test_mlp.py
Nicholas Pfaff 9f487a464f
Implement nerfacto alpha transparency training (#2165)
* Implement nerfacto alpha transparency training

* Stop adding all ones alpha channel and clean up blend_background

* Make background_color a required argument in blend_background

* Enable alpha transparent training by default

* Improve background_color typing

* Blend uniform background color for metric computation

* Fix typing error

* Clean up typing

* Fix background_color to outputs assignment

* Model outputs returns unblended RGB (black bg) for random bg

* Update renderers

* Fix comments

* Add support for transparent BG for other methods

* Minor refac

* Fix get_background_color

* Fix typing error for blend_background

* Fix comments

* Export utils support transparency

* Pylint fix

* Fix pcd export masking

* Filter pcd view directions based on opacity

* Clean up get_rgba_image

---------

Co-authored-by: Jonas Kulhanek <jonas.kulhanek@live.com>
2023-07-18 12:54:52 +02:00

32 lines
574 B
Python

"""
MLP Test
"""
import torch
from torch import nn
from nerfstudio.field_components.mlp import MLP
def test_mlp():
"""Test mlp"""
in_dim = 6
out_dim = 10
num_layers = 2
layer_width = 32
out_activation = nn.ReLU()
mlp = MLP(
in_dim=in_dim, out_dim=out_dim, num_layers=num_layers, layer_width=layer_width, out_activation=out_activation
)
assert mlp.get_out_dim() == out_dim
x = torch.ones((9, in_dim))
mlp.build_nn_modules()
y = mlp(x)
assert y.shape[-1] == out_dim
if __name__ == "__main__":
test_mlp()