mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-17 05:14:15 +08:00
Add average_init_density to improve robustness of nerfacto training (#2834)
This commit is contained in:
4 files changed
+14
-2
No files matched your search
@@ -56,12 +56,14 @@ class HashMLPDensityField(Field):
|
||||
base_res: int = 16,
|
||||
log2_hashmap_size: int = 18,
|
||||
features_per_level: int = 2,
|
||||
average_init_density: float = 1.0,
|
||||
implementation: Literal["tcnn", "torch"] = "tcnn",
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self.register_buffer("aabb", aabb)
|
||||
self.spatial_distortion = spatial_distortion
|
||||
self.use_linear = use_linear
|
||||
self.average_init_density = average_init_density
|
||||
|
||||
self.register_buffer("max_res", torch.tensor(max_res))
|
||||
self.register_buffer("num_levels", torch.tensor(num_levels))
|
||||
@@ -111,7 +113,7 @@ class HashMLPDensityField(Field):
|
||||
# Rectifying the density with an exponential is much more stable than a ReLU or
|
||||
# softplus, because it enables high post-activation (float32) density outputs
|
||||
# from smaller internal (float16) parameters.
|
||||
density = trunc_exp(density_before_activation)
|
||||
density = self.average_init_density * trunc_exp(density_before_activation)
|
||||
density = density * selector[..., None]
|
||||
return density, None
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ class NerfactoField(Field):
|
||||
use_pred_normals: bool = False,
|
||||
use_average_appearance_embedding: bool = False,
|
||||
spatial_distortion: Optional[SpatialDistortion] = None,
|
||||
average_init_density: float = 1.0,
|
||||
implementation: Literal["tcnn", "torch"] = "tcnn",
|
||||
) -> None:
|
||||
super().__init__()
|
||||
@@ -116,6 +117,7 @@ class NerfactoField(Field):
|
||||
self.use_pred_normals = use_pred_normals
|
||||
self.pass_semantic_gradients = pass_semantic_gradients
|
||||
self.base_res = base_res
|
||||
self.average_init_density = average_init_density
|
||||
self.step = 0
|
||||
|
||||
self.direction_encoding = SHEncoding(
|
||||
@@ -218,7 +220,7 @@ class NerfactoField(Field):
|
||||
# Rectifying the density with an exponential is much more stable than a ReLU or
|
||||
# softplus, because it enables high post-activation (float32) density outputs
|
||||
# from smaller internal (float16) parameters.
|
||||
density = trunc_exp(density_before_activation.to(positions))
|
||||
density = self.average_init_density * trunc_exp(density_before_activation.to(positions))
|
||||
density = density * selector[..., None]
|
||||
return density, base_mlp_out
|
||||
|
||||
|
||||
Reference in new issue
Block a user