annealing for proposal network (#560)

* merged

* adding depth

* added annealing

* reverted launch.json

* reverted hidden dim

* changed loss

* losses match master

* comments

* fix black
This commit is contained in:
Ethan Weber authored and GitHub committed 2022-09-27 12:32:04 -07:00
1 parent 203d36c433
commit 1267045aed
8 files changed
+104 -30

No files matched your search

+6 -6
View File
@@ -70,25 +70,25 @@ def lossfun_outer(t, w, t_env, w_env):
return torch.clip(w - w_outer, min=0) ** 2 / (w + EPS)
def ray_samples_to_sdist(ray_samples, near_plane, far_plane):
def ray_samples_to_sdist(ray_samples):
"""Convert ray samples to s space"""
starts = (ray_samples.frustums.starts - near_plane) / (far_plane - near_plane)
ends = (ray_samples.frustums.ends - near_plane) / (far_plane - near_plane)
starts = ray_samples.spacing_starts
ends = ray_samples.spacing_ends
sdist = torch.cat([starts[..., 0], ends[..., -1:, 0]], dim=-1) # (num_rays, num_samples + 1)
return sdist
def interlevel_loss(weights_list, ray_samples_list, near_plane, far_plane):
def interlevel_loss(weights_list, ray_samples_list):
"""Calculates the proposal loss in the MipNeRF-360 paper.
https://github.com/kakaobrain/NeRF-Factory/blob/f61bb8744a5cb4820a4d968fb3bfbed777550f4a/src/model/mipnerf360/model.py#L515
https://github.com/google-research/multinerf/blob/b02228160d3179300c7d499dca28cb9ca3677f32/internal/train_utils.py#L133
"""
c = ray_samples_to_sdist(ray_samples_list[-1], near_plane, far_plane).detach()
c = ray_samples_to_sdist(ray_samples_list[-1]).detach()
w = weights_list[-1][..., 0].detach()
loss_interlevel = 0.0
for ray_samples, weights in zip(ray_samples_list[:-1], weights_list[:-1]):
sdist = ray_samples_to_sdist(ray_samples, near_plane, far_plane)
sdist = ray_samples_to_sdist(ray_samples)
cp = sdist # (num_rays, num_samples + 1)
wp = weights[..., 0] # (num_rays, num_samples)
loss_interlevel += torch.mean(lossfun_outer(c, w, cp, wp))