mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-22 07:35:26 +08:00
torchtyping => jaxtyping (#1838)
* Run `ruff --fix` * Add jaxtyping migration script * Run migration scripts + ruff + black * Merge remote-tracking branch 'origin/main' into brent/jaxtyping * black * Fix lint * fix lint * Cleanup and more specific types * Fixed annotation errors * Fix more errors * Fix annotation * Delete _torchtyping_to_jaxtyping.py --------- Co-authored-by: Matt Tancik <mattt4001@gmail.com>
This commit is contained in:
1 parent
9b6290ea43
commit
6ba2a18b2b
65 files changed
+597
-531
No files matched your search
@@ -187,11 +187,12 @@ class NerfactoModel(Model):
|
||||
self.density_fns.extend([network.density_fn for network in self.proposal_networks])
|
||||
|
||||
# Samplers
|
||||
update_schedule = lambda step: np.clip(
|
||||
np.interp(step, [0, self.config.proposal_warmup], [0, self.config.proposal_update_every]),
|
||||
1,
|
||||
self.config.proposal_update_every,
|
||||
)
|
||||
def update_schedule(step):
|
||||
return np.clip(
|
||||
np.interp(step, [0, self.config.proposal_warmup], [0, self.config.proposal_update_every]),
|
||||
1,
|
||||
self.config.proposal_update_every,
|
||||
)
|
||||
|
||||
# Change proposal network initial sampler if uniform
|
||||
initial_sampler = None # None is for piecewise as default (see ProposalNetworkSampler)
|
||||
@@ -244,7 +245,10 @@ class NerfactoModel(Model):
|
||||
def set_anneal(step):
|
||||
# https://arxiv.org/pdf/2111.12077.pdf eq. 18
|
||||
train_frac = np.clip(step / N, 0, 1)
|
||||
bias = lambda x, b: (b * x) / ((b - 1) * x + 1)
|
||||
|
||||
def bias(x, b):
|
||||
return b * x / ((b - 1) * x + 1)
|
||||
|
||||
anneal = bias(train_frac, self.config.proposal_weights_anneal_slope)
|
||||
self.proposal_sampler.set_anneal(anneal)
|
||||
|
||||
|
||||
@@ -140,11 +140,13 @@ class NerfplayerNerfactoModel(NerfactoModel):
|
||||
self.density_fns.extend([network.density_fn for network in self.proposal_networks])
|
||||
|
||||
# Samplers
|
||||
update_schedule = lambda step: np.clip(
|
||||
np.interp(step, [0, self.config.proposal_warmup], [0, self.config.proposal_update_every]),
|
||||
1,
|
||||
self.config.proposal_update_every,
|
||||
)
|
||||
def update_schedule(step):
|
||||
return np.clip(
|
||||
np.interp(step, [0, self.config.proposal_warmup], [0, self.config.proposal_update_every]),
|
||||
1,
|
||||
self.config.proposal_update_every,
|
||||
)
|
||||
|
||||
self.proposal_sampler = ProposalNetworkSampler(
|
||||
num_nerf_samples_per_ray=self.config.num_nerf_samples_per_ray,
|
||||
num_proposal_samples_per_ray=self.config.num_proposal_samples_per_ray,
|
||||
@@ -246,7 +248,10 @@ class NerfplayerNerfactoModel(NerfactoModel):
|
||||
if "depth_image" in batch.keys() and self.config.depth_weight > 0:
|
||||
mask = (batch["depth_image"] != 0).view([-1])
|
||||
loss_dict["depth_loss"] = 0
|
||||
l = lambda x: self.config.depth_weight * (x - batch["depth_image"][mask]).pow(2).mean()
|
||||
|
||||
def l(x):
|
||||
return self.config.depth_weight * (x - batch["depth_image"][mask]).pow(2).mean()
|
||||
|
||||
loss_dict["depth_loss"] = l(outputs["depth"][mask])
|
||||
for i in range(self.config.num_proposal_iterations):
|
||||
loss_dict["depth_loss"] += l(outputs[f"prop_depth_{i}"][mask])
|
||||
|
||||
@@ -119,7 +119,8 @@ class NeuSFactoModel(NeuSModel):
|
||||
self.density_fns.extend([network.density_fn for network in self.proposal_networks])
|
||||
|
||||
# update proposal network every iterations
|
||||
update_schedule = lambda step: -1
|
||||
def update_schedule(_):
|
||||
return -1
|
||||
|
||||
initial_sampler = UniformSampler(single_jitter=self.config.use_single_jitter)
|
||||
self.proposal_sampler = ProposalNetworkSampler(
|
||||
@@ -149,7 +150,10 @@ class NeuSFactoModel(NeuSModel):
|
||||
def set_anneal(step: int):
|
||||
# https://arxiv.org/pdf/2111.12077.pdf eq. 18
|
||||
train_frac = np.clip(step / N, 0, 1)
|
||||
bias = lambda x, b: (b * x) / ((b - 1) * x + 1)
|
||||
|
||||
def bias(x, b):
|
||||
return b * x / ((b - 1) * x + 1)
|
||||
|
||||
anneal = bias(train_frac, self.config.proposal_weights_anneal_slope)
|
||||
self.proposal_sampler.set_anneal(anneal)
|
||||
|
||||
|
||||
@@ -160,7 +160,10 @@ class SemanticNerfWModel(Model):
|
||||
def set_anneal(step):
|
||||
# https://arxiv.org/pdf/2111.12077.pdf eq. 18
|
||||
train_frac = np.clip(step / N, 0, 1)
|
||||
bias = lambda x, b: (b * x) / ((b - 1) * x + 1)
|
||||
|
||||
def bias(x, b):
|
||||
return b * x / ((b - 1) * x + 1)
|
||||
|
||||
anneal = bias(train_frac, self.config.proposal_weights_anneal_slope)
|
||||
self.proposal_sampler.set_anneal(anneal)
|
||||
|
||||
|
||||
Reference in new issue
Block a user