mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-03 22:38:48 +08:00
Small patches and configs
This commit is contained in:
1 parent
18df29fe1a
commit
295dc00c22
6 files changed
+61
-19
No files matched your search
@@ -76,6 +76,14 @@ class DreamFusionModelConfig(ModelConfig):
|
||||
"""Initial strength of center density"""
|
||||
sphere_collider: bool = True
|
||||
"""Use spherical collider instead of box"""
|
||||
target_transmittance_start: float = 0.8
|
||||
"""target transmittance for opacity penalty. This is the percent of the scene that is
|
||||
background when rendered at the start of training"""
|
||||
target_transmittance_end: float = 0.4
|
||||
"""target transmittance for opacity penalty. This is the percent of the scene that is
|
||||
background when rendered at the end of training"""
|
||||
transmittance_end_schedule: int = 1000
|
||||
"""number of iterations to reach target_transmittance_end"""
|
||||
|
||||
|
||||
class DreamFusionModel(Model):
|
||||
@@ -97,6 +105,7 @@ class DreamFusionModel(Model):
|
||||
self.train_normals = False
|
||||
self.train_shaded = False
|
||||
self.density_strength = 1.0
|
||||
self.target_transmittance = config.target_transmittance_start
|
||||
super().__init__(config=config, **kwargs)
|
||||
|
||||
def get_training_callbacks(
|
||||
@@ -119,6 +128,13 @@ class DreamFusionModel(Model):
|
||||
):
|
||||
self.train_shaded = True
|
||||
|
||||
def update_target_transmittance(
|
||||
self, training_callback_attributes: TrainingCallbackAttributes, step: int # pylint: disable=unused-argument
|
||||
):
|
||||
self.target_transmittance -= (1 / self.config.transmittance_end_schedule) * (
|
||||
self.config.target_transmittance_start - self.config.target_transmittance_end
|
||||
)
|
||||
|
||||
callbacks = [
|
||||
TrainingCallback(
|
||||
where_to_run=[TrainingCallbackLocation.AFTER_TRAIN_ITERATION],
|
||||
@@ -138,6 +154,12 @@ class DreamFusionModel(Model):
|
||||
func=start_shaded_training,
|
||||
args=[self, training_callback_attributes],
|
||||
),
|
||||
TrainingCallback(
|
||||
where_to_run=[TrainingCallbackLocation.AFTER_TRAIN_ITERATION],
|
||||
iters=(self.config.transmittance_end_schedule,),
|
||||
func=update_target_transmittance,
|
||||
args=[self, training_callback_attributes],
|
||||
),
|
||||
]
|
||||
return callbacks
|
||||
|
||||
@@ -260,7 +282,7 @@ class DreamFusionModel(Model):
|
||||
)
|
||||
|
||||
assert weights.shape[-1] == 1
|
||||
outputs["alphas_loss"] = torch.sqrt(torch.sum(weights, dim=-2) ** 2 + 0.01).mean()
|
||||
outputs["alphas_loss"] = torch.sqrt(torch.sum(weights, dim=-2) ** 2 + 0.01)
|
||||
|
||||
return outputs
|
||||
|
||||
@@ -280,7 +302,15 @@ class DreamFusionModel(Model):
|
||||
outputs["rendered_pred_normal_loss"]
|
||||
)
|
||||
|
||||
loss_dict["alphas_loss"] = outputs["alphas_loss"]
|
||||
loss_dict["alphas_loss"] = outputs["alphas_loss"].mean()
|
||||
|
||||
assert (
|
||||
self.target_transmittance >= self.config.target_transmittance_end
|
||||
and self.target_transmittance <= self.config.target_transmittance_start
|
||||
)
|
||||
loss_dict["opacity_loss"] = -torch.minimum(
|
||||
(1 - outputs["accumulation"]).mean(), torch.tensor(self.target_transmittance)
|
||||
)
|
||||
|
||||
return loss_dict
|
||||
|
||||
|
||||
Reference in new issue
Block a user