mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-19 22:25:44 +08:00
Triplanes (#1456)
* Triplanes working * Doing the TODOs, better variable names --------- Co-authored-by: Matthew Tancik <tancik@berkeley.edu>
This commit is contained in:
1 parent
9e68a46abe
commit
50dc5d6cd7
2 files changed
+121
-10
No files matched your search
@@ -27,6 +27,7 @@ from torch.nn import Parameter
|
||||
from torchmetrics import PeakSignalNoiseRatio
|
||||
from torchmetrics.functional import structural_similarity_index_measure
|
||||
from torchmetrics.image.lpip import LearnedPerceptualImagePatchSimilarity
|
||||
from typing_extensions import Literal
|
||||
|
||||
from nerfstudio.cameras.rays import RayBundle
|
||||
from nerfstudio.configs.config_utils import to_immutable_dict
|
||||
@@ -35,7 +36,12 @@ from nerfstudio.engine.callbacks import (
|
||||
TrainingCallbackAttributes,
|
||||
TrainingCallbackLocation,
|
||||
)
|
||||
from nerfstudio.field_components.encodings import NeRFEncoding, TensorVMEncoding
|
||||
from nerfstudio.field_components.encodings import (
|
||||
NeRFEncoding,
|
||||
TensorCPEncoding,
|
||||
TensorVMEncoding,
|
||||
TriplaneEncoding,
|
||||
)
|
||||
from nerfstudio.field_components.field_heads import FieldHeadNames
|
||||
from nerfstudio.fields.tensorf_field import TensoRFField
|
||||
from nerfstudio.model_components.losses import MSELoss
|
||||
@@ -72,6 +78,7 @@ class TensoRFModelConfig(ModelConfig):
|
||||
"""Number of components in color encoding"""
|
||||
appearance_dim: int = 27
|
||||
"""Number of channels for color encoding"""
|
||||
tensorf_encoding: Literal["triplane", "vm", "cp"] = "vm"
|
||||
|
||||
|
||||
class TensoRFModel(Model):
|
||||
@@ -166,14 +173,35 @@ class TensoRFModel(Model):
|
||||
super().populate_modules()
|
||||
|
||||
# setting up fields
|
||||
density_encoding = TensorVMEncoding(
|
||||
resolution=self.init_resolution,
|
||||
num_components=self.num_den_components,
|
||||
)
|
||||
color_encoding = TensorVMEncoding(
|
||||
resolution=self.init_resolution,
|
||||
num_components=self.num_color_components,
|
||||
)
|
||||
if self.config.tensorf_encoding == "vm":
|
||||
density_encoding = TensorVMEncoding(
|
||||
resolution=self.init_resolution,
|
||||
num_components=self.num_den_components,
|
||||
)
|
||||
color_encoding = TensorVMEncoding(
|
||||
resolution=self.init_resolution,
|
||||
num_components=self.num_color_components,
|
||||
)
|
||||
elif self.config.tensorf_encoding == "cp":
|
||||
density_encoding = TensorCPEncoding(
|
||||
resolution=self.init_resolution,
|
||||
num_components=self.num_den_components,
|
||||
)
|
||||
color_encoding = TensorCPEncoding(
|
||||
resolution=self.init_resolution,
|
||||
num_components=self.num_color_components,
|
||||
)
|
||||
elif self.config.tensorf_encoding == "triplane":
|
||||
density_encoding = TriplaneEncoding(
|
||||
resolution=self.init_resolution,
|
||||
num_components=self.num_den_components,
|
||||
)
|
||||
color_encoding = TriplaneEncoding(
|
||||
resolution=self.init_resolution,
|
||||
num_components=self.num_color_components,
|
||||
)
|
||||
else:
|
||||
raise ValueError(f"Encoding {self.config.tensorf_encoding} not supported")
|
||||
|
||||
feature_encoding = NeRFEncoding(in_dim=self.appearance_dim, num_frequencies=2, min_freq_exp=0, max_freq_exp=2)
|
||||
direction_encoding = NeRFEncoding(in_dim=3, num_frequencies=2, min_freq_exp=0, max_freq_exp=2)
|
||||
|
||||
Reference in new issue
Block a user