mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 14:58:55 +08:00
fixes for nerf synthetic dataset (#1507)
* fixes for nerf synthetic dataset * restore eval script * fix format with black
This commit is contained in:
1 parent
92c9cee4c7
commit
7dc7129cf8
4 files changed
+15
-2
No files matched your search
@@ -102,6 +102,9 @@ class HashMLPDensityField(Field):
|
|||||||
positions = (positions + 2.0) / 4.0
|
positions = (positions + 2.0) / 4.0
|
||||||
else:
|
else:
|
||||||
positions = SceneBox.get_normalized_positions(ray_samples.frustums.get_positions(), self.aabb)
|
positions = SceneBox.get_normalized_positions(ray_samples.frustums.get_positions(), self.aabb)
|
||||||
|
# Make sure the tcnn gets inputs between 0 and 1.
|
||||||
|
selector = ((positions > 0.0) & (positions < 1.0)).all(dim=-1)
|
||||||
|
positions = positions * selector[..., None]
|
||||||
positions_flat = positions.view(-1, 3)
|
positions_flat = positions.view(-1, 3)
|
||||||
if not self.use_linear:
|
if not self.use_linear:
|
||||||
density_before_activation = (
|
density_before_activation = (
|
||||||
@@ -115,6 +118,7 @@ class HashMLPDensityField(Field):
|
|||||||
# softplus, because it enables high post-activation (float32) density outputs
|
# softplus, because it enables high post-activation (float32) density outputs
|
||||||
# from smaller internal (float16) parameters.
|
# from smaller internal (float16) parameters.
|
||||||
density = trunc_exp(density_before_activation)
|
density = trunc_exp(density_before_activation)
|
||||||
|
density = density * selector[..., None]
|
||||||
return density, None
|
return density, None
|
||||||
|
|
||||||
def get_outputs(self, ray_samples: RaySamples, density_embedding: Optional[TensorType] = None):
|
def get_outputs(self, ray_samples: RaySamples, density_embedding: Optional[TensorType] = None):
|
||||||
|
|||||||
@@ -237,6 +237,9 @@ class TCNNNerfactoField(Field):
|
|||||||
positions = (positions + 2.0) / 4.0
|
positions = (positions + 2.0) / 4.0
|
||||||
else:
|
else:
|
||||||
positions = SceneBox.get_normalized_positions(ray_samples.frustums.get_positions(), self.aabb)
|
positions = SceneBox.get_normalized_positions(ray_samples.frustums.get_positions(), self.aabb)
|
||||||
|
# Make sure the tcnn gets inputs between 0 and 1.
|
||||||
|
selector = ((positions > 0.0) & (positions < 1.0)).all(dim=-1)
|
||||||
|
positions = positions * selector[..., None]
|
||||||
self._sample_locations = positions
|
self._sample_locations = positions
|
||||||
if not self._sample_locations.requires_grad:
|
if not self._sample_locations.requires_grad:
|
||||||
self._sample_locations.requires_grad = True
|
self._sample_locations.requires_grad = True
|
||||||
@@ -249,6 +252,7 @@ class TCNNNerfactoField(Field):
|
|||||||
# softplus, because it enables high post-activation (float32) density outputs
|
# softplus, because it enables high post-activation (float32) density outputs
|
||||||
# from smaller internal (float16) parameters.
|
# from smaller internal (float16) parameters.
|
||||||
density = trunc_exp(density_before_activation.to(positions))
|
density = trunc_exp(density_before_activation.to(positions))
|
||||||
|
density = density * selector[..., None]
|
||||||
return density, base_mlp_out
|
return density, base_mlp_out
|
||||||
|
|
||||||
def get_outputs(self, ray_samples: RaySamples, density_embedding: Optional[TensorType] = None):
|
def get_outputs(self, ray_samples: RaySamples, density_embedding: Optional[TensorType] = None):
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ class NerfactoModelConfig(ModelConfig):
|
|||||||
"""Whether use single jitter or not for the proposal networks."""
|
"""Whether use single jitter or not for the proposal networks."""
|
||||||
predict_normals: bool = False
|
predict_normals: bool = False
|
||||||
"""Whether to predict normals or not."""
|
"""Whether to predict normals or not."""
|
||||||
|
disable_scene_contraction: bool = False
|
||||||
|
"""Whether to disable scene contraction or not."""
|
||||||
|
|
||||||
|
|
||||||
class NerfactoModel(Model):
|
class NerfactoModel(Model):
|
||||||
@@ -135,7 +137,10 @@ class NerfactoModel(Model):
|
|||||||
"""Set the fields and modules."""
|
"""Set the fields and modules."""
|
||||||
super().populate_modules()
|
super().populate_modules()
|
||||||
|
|
||||||
scene_contraction = SceneContraction(order=float("inf"))
|
if self.config.disable_scene_contraction:
|
||||||
|
scene_contraction = None
|
||||||
|
else:
|
||||||
|
scene_contraction = SceneContraction(order=float("inf"))
|
||||||
|
|
||||||
# Fields
|
# Fields
|
||||||
self.field = TCNNNerfactoField(
|
self.field = TCNNNerfactoField(
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ fi
|
|||||||
method_opts=()
|
method_opts=()
|
||||||
if [ "$method_name" = "nerfacto" ]; then
|
if [ "$method_name" = "nerfacto" ]; then
|
||||||
# https://github.com/nerfstudio-project/nerfstudio/issues/806#issuecomment-1284327844
|
# https://github.com/nerfstudio-project/nerfstudio/issues/806#issuecomment-1284327844
|
||||||
method_opts=(--pipeline.model.background-color white --pipeline.model.proposal-initial-sampler uniform --pipeline.model.near-plane 2. --pipeline.model.far-plane 6. --pipeline.datamanager.camera-optimizer.mode off --pipeline.model.use-average-appearance-embedding False)
|
method_opts=(--pipeline.model.background-color white --pipeline.model.proposal-initial-sampler uniform --pipeline.model.near-plane 2. --pipeline.model.far-plane 6. --pipeline.datamanager.camera-optimizer.mode off --pipeline.model.use-average-appearance-embedding False --pipeline.model.distortion-loss-mult 0 --pipeline.model.disable-scene-contraction True)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shift $((OPTIND-1))
|
shift $((OPTIND-1))
|
||||||
|
|||||||
Reference in new issue
Block a user