-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
distortion loss impl. #244
base: main
Are you sure you want to change the base?
Conversation
@liruilong940607, I think there are some version issues with the Nerfacc library. I have Nerfacc Version: 0.5.3 installed (with The error a user gets: This can be fixed by installing from the git source but just a heads up... |
) | ||
torch.testing.assert_close(render_colors, _render_colors) | ||
torch.testing.assert_close(render_alphas, _render_alphas) | ||
torch.testing.assert_close(render_distloss, _render_distloss) | ||
|
||
# backward | ||
v_render_colors = torch.randn_like(render_colors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an issue, just a general question regarding the use of torch.autograd.grad(outputs * v_outputs ,inputs)
in the gradient tests. Why do we scale outputs by these random v_outputs
weights? Shouldn't torch.autograd.grad(outputs, inputs)
suffice for gradient checking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
torch.autograd.grad
needs to take in a scalar in the first argument, which is essentially the loss. So here I'm testing against this formula:
dL_d(input) = dL_d(output) * d(output)/d(input)
Since we don't have the loss formula, I'll using a random tensor (v_output
) to mimic dL_d(output)
, so the "loss" can be set to be loss = (output * v_output).sum()
.
Then the testing of dL_d(input) is:
torch.autograd.grad((outputs * v_outputs).sum() ,inputs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool color theme! What theme are you using here?
The reason I haven't merge this PR is that I didn't find this distortion loss to be helpful on ANY of the scenes in MipNeRF 360, which is a bit frustrated and not expected.
Let me know if you find anything otherwise!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing the reason that this distortion loss isn't useful might have something to do with the imperfect depth accumulation formulation that we are currently using. The depth formulation from Gaussian Opacity Fields or RaDe-GS seems to be more accurate, which might be a prerequisite for distortion loss to work.
Or, maybe its just that there aren't many floaters in these GS scenes anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For those like me who were wondering what the awesome color scheme was, I think I tracked it down to cmr.voltage
. https://cmasher.readthedocs.io/user/sequential/voltage.html
@FantasticOven2 I think the speckle artifacts you have in your normal image are from overflowing uint8 in the visualization. You may need to clamp or normalize your normals. |
Hi Ruilong, do you have any plans to merge this? I think it would be helpful in some more underconstrained settings. |
I haven't got a case where I find it useful and that's why I wasn't quite motivated to spend further efforts on merging it. But I guess it's true that all the cases I tried are well constrained. I could try to find some cycles to merge this but no guarantee on the timeline! |
Implement distortion loss for 3DGS from Mip-NeRF 360:
Note: Since the distortion loss is a per-pixel value, I implement it as a per-pixel map rendered from the
rasterization()
function, with the same resolution with the rendered image. This could be reduced into a scalar with a.mean()
call on it for backward. Having the distortion loss as a map instead of a scalar could be useful for visualization and analysis purposes.