mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-01 21:39:06 +08:00
Computing and predicting normals (#905)
* staring normals PR * code runs but visualization looks bad * Camera and world coordinate conventions (#889) * documented coordinate conventions without a figure for now * another sentence * update frames docs * explain intrinsics and extrinsics * more comments * fix build * Start viewer with more accurate speed calculation (#899) Start viewer with more accurate speed calc * Minor doc updates (#903) * fix conflicts * code runs but visualization looks bad * normals implemented and vis fixed. still debugging quality * minor name change * comment * fix black * lint * predicting normals * adding detach * predicted normals * improved normals prediction performance * cleaning code * cleaning code * cleaning code * adding type to function param * fixing tensorf forward func * reverting tensorf changes * fix style with tensorf field * adding normals check to tensorffield Co-authored-by: Matthew Tancik <tancik@berkeley.edu> Co-authored-by: terrance <terrance.3512@gmail.com>
This commit is contained in:
8 files changed
+204
-17
No files matched your search
@@ -18,6 +18,7 @@ Collection of render heads
|
||||
from enum import Enum
|
||||
from typing import Callable, Optional, Union
|
||||
|
||||
import torch
|
||||
from torch import nn
|
||||
from torchtyping import TensorType
|
||||
|
||||
@@ -30,12 +31,12 @@ class FieldHeadNames(Enum):
|
||||
RGB = "rgb"
|
||||
SH = "sh"
|
||||
DENSITY = "density"
|
||||
NORMALS = "normals"
|
||||
PRED_NORMALS = "pred_normals"
|
||||
UNCERTAINTY = "uncertainty"
|
||||
TRANSIENT_RGB = "transient_rgb"
|
||||
TRANSIENT_DENSITY = "transient_density"
|
||||
SEMANTICS = "semantics"
|
||||
SEMANTICS_STUFF = "semantics_stuff"
|
||||
SEMANTICS_THING = "semantics_thing"
|
||||
|
||||
|
||||
class FieldHead(FieldComponent):
|
||||
@@ -171,7 +172,7 @@ class TransientDensityFieldHead(FieldHead):
|
||||
|
||||
|
||||
class SemanticFieldHead(FieldHead):
|
||||
"""Semantic stuff output
|
||||
"""Semantic output
|
||||
|
||||
Args:
|
||||
num_classes: Number of semantic classes
|
||||
@@ -181,3 +182,21 @@ class SemanticFieldHead(FieldHead):
|
||||
|
||||
def __init__(self, num_classes: int, in_dim: Optional[int] = None) -> None:
|
||||
super().__init__(in_dim=in_dim, out_dim=num_classes, field_head_name=FieldHeadNames.SEMANTICS, activation=None)
|
||||
|
||||
|
||||
class PredNormalsFieldHead(FieldHead):
|
||||
"""Predicted normals output.
|
||||
|
||||
Args:
|
||||
in_dim: input dimension. If not defined in constructor, it must be set later.
|
||||
activation: output head activation
|
||||
"""
|
||||
|
||||
def __init__(self, in_dim: Optional[int] = None, activation: Optional[nn.Module] = nn.Tanh()) -> None:
|
||||
super().__init__(in_dim=in_dim, out_dim=3, field_head_name=FieldHeadNames.PRED_NORMALS, activation=activation)
|
||||
|
||||
def forward(self, in_tensor: TensorType["bs":..., "in_dim"]) -> TensorType["bs":..., "out_dim"]:
|
||||
"""Needed to normalize the output into valid normals."""
|
||||
out_tensor = super().forward(in_tensor)
|
||||
out_tensor = torch.nn.functional.normalize(out_tensor, dim=-1)
|
||||
return out_tensor
|
||||
Reference in new issue
Block a user