mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-06 07:48:50 +08:00
Merge branch 'master' of github.com:ethanweber/mattport
This commit is contained in:
commit
cea1d115d2
22 files changed
+708
-88
No files matched your search
@@ -0,0 +1,30 @@
|
||||
"""
|
||||
Code for embeddings.
|
||||
"""
|
||||
|
||||
|
||||
import torch
|
||||
from torchtyping import TensorType
|
||||
from mattport.nerf.field_modules.base import FieldModule
|
||||
|
||||
|
||||
class Embedding(FieldModule):
|
||||
"""Index into embeddings."""
|
||||
|
||||
def __init__(self, in_dim: int, out_dim: int) -> None:
|
||||
"""
|
||||
Args:
|
||||
in_dim (int): Number of embeddings
|
||||
out_dim (int): Dimension of the embedding vectors
|
||||
"""
|
||||
super().__init__()
|
||||
self.in_dim = in_dim
|
||||
self.out_dim = out_dim
|
||||
self.build_nn_modules()
|
||||
|
||||
def build_nn_modules(self) -> None:
|
||||
self.embedding = torch.nn.Embedding(self.in_dim, self.out_dim)
|
||||
|
||||
def forward(self, in_tensor: TensorType[..., "input_dim"]) -> TensorType[..., "output_dim"]:
|
||||
"""Call forward"""
|
||||
return self.embedding(in_tensor)
|
||||
@@ -15,6 +15,11 @@ class FieldHeadNames(Enum):
|
||||
|
||||
RGB = "rgb"
|
||||
DENSITY = "density"
|
||||
UNCERTAINTY = "uncertainty"
|
||||
TRANSIENT_RGB = "transient_rgb"
|
||||
TRANSIENT_DENSITY = "transient_density"
|
||||
SEMANTICS_STUFF = "semantics_stuff"
|
||||
SEMANTICS_THING = "semantics_thing"
|
||||
|
||||
|
||||
class FieldHead(FieldModule):
|
||||
@@ -91,3 +96,31 @@ class SHFieldHead(FieldHead):
|
||||
"""
|
||||
out_dim = channels * levels**2
|
||||
super().__init__(in_dim, out_dim=out_dim, field_head_name=FieldHeadNames.RGB, activation=activation)
|
||||
|
||||
|
||||
class UncertaintyFieldHead(FieldHead):
|
||||
"""Uncertainty output"""
|
||||
|
||||
def __init__(self, in_dim: int, activation: Optional[nn.Module] = nn.Softplus()) -> None:
|
||||
super().__init__(in_dim, out_dim=1, field_head_name=FieldHeadNames.UNCERTAINTY, activation=activation)
|
||||
|
||||
|
||||
class TransientRGBHead(FieldHead):
|
||||
"""Transient RGB output"""
|
||||
|
||||
def __init__(self, in_dim: int, activation: Optional[nn.Module] = nn.Sigmoid()) -> None:
|
||||
super().__init__(in_dim, out_dim=3, field_head_name=FieldHeadNames.TRANSIENT_RGB, activation=activation)
|
||||
|
||||
|
||||
class TransientDensityHead(FieldHead):
|
||||
"""Transient density output"""
|
||||
|
||||
def __init__(self, in_dim: int, activation: Optional[nn.Module] = nn.Softplus()) -> None:
|
||||
super().__init__(in_dim, out_dim=1, field_head_name=FieldHeadNames.TRANSIENT_DENSITY, activation=activation)
|
||||
|
||||
|
||||
class SemanticStuffHead(FieldHead):
|
||||
"""Semantic stuff output"""
|
||||
|
||||
def __init__(self, in_dim: int, num_classes: int) -> None:
|
||||
super().__init__(in_dim, out_dim=num_classes, field_head_name=FieldHeadNames.SEMANTICS_STUFF, activation=None)
|
||||
Reference in new issue
Block a user