Skip to content

Commit

Permalink
Fix distortion-loss to skip first term per sample / use inner zero sum (
Browse files Browse the repository at this point in the history
#281)

Correctly evaluate Eq (2) of

Improved Direct Voxel Grid Optimization for Radiance Fields Reconstruction
https://arxiv.org/pdf/2206.05085.pdf
  • Loading branch information
ph03 authored Feb 1, 2024
1 parent 5946080 commit bfbf027
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nerfacc/losses.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from torch import Tensor

from .scan import inclusive_sum
from .scan import exclusive_sum
from .volrend import accumulate_along_rays


Expand Down Expand Up @@ -33,8 +33,8 @@ def distortion(
t_mids = 0.5 * (t_starts + t_ends)
t_deltas = t_ends - t_starts
loss_uni = (1 / 3) * (t_deltas * weights.pow(2))
loss_bi_0 = weights * t_mids * inclusive_sum(weights, indices=ray_indices)
loss_bi_1 = weights * inclusive_sum(weights * t_mids, indices=ray_indices)
loss_bi_0 = weights * t_mids * exclusive_sum(weights, indices=ray_indices)
loss_bi_1 = weights * exclusive_sum(weights * t_mids, indices=ray_indices)
loss_bi = 2 * (loss_bi_0 - loss_bi_1)
loss = loss_uni + loss_bi
loss = accumulate_along_rays(loss, None, ray_indices, n_rays)
Expand Down

0 comments on commit bfbf027

Please sign in to comment.