-
Notifications
You must be signed in to change notification settings - Fork 348
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
Add camera pose and projection gradient flow #123
Conversation
|
@ichsan2895, |
Pillow | ||
pytorch3d @ git+https://github.com/facebookresearch/[email protected] |
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.
It seems like only the tests rely on p3d, it would be nice to remove as a dependency since it's a pretty big one and if we only need it for matrix transforms there's more common lightweight options like scipy.
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.
Unfortunately I needed the matrix transforms to be differentiable so that the gradients can flow into the Euler angle and position parameters. I tried implementing my own transformations, but ran into some instability in training. I have been using se3_exp_map
and se3_log_map
, but if you have any replacements I am open to try them.
It would be good to compare these camera grads to the camera grads from the torch implementation with autograd, this PR adds a torch implementation which should have correct (although slow) gradients since they're computed from torch. |
Also this would be simpler without the redundant |
There's also a simpler way of achieving the same goal of optimizing the view matrix, shown here: #127 |
I'm not certain if removing the |
7540e37
to
d4fd07a
Compare
@jh-surh I elaborated this here #97 (comment). Everything that can be implemented with projection matrices can also be implemented by extending the "intrinsics" to support other camera models than the ideal pinhole (fx,fy,cx,cy). It's also relatively simple to convert any typical (non-ortho) OpenGL projection matrix to (fx,fy,cx,cy) format (and throw away the near & far clip terms which do not matter in this context) |
Would it require work "extending the intrinsics to support other camera models" in terms of calculating gradients? If so, it seems like something we can do in a separate PR since the current nerfstudio implementation uses projmat for its own projection matrix.
Thank you for your suggestion! I found a bug trying to compare the gradient w.r.t. the torch implementation. I have fixed it and updated the test script and have passed the project gaussian test. Seems like the current main branch is failing 3 of the test scripts though. Someone should look at that. |
Yes, and I agree that such stuff should definitely be implemented in some other PR. However, the projection matrix is fed to gsplat is not needed by Nersftudio for any other purpose, as demonstrated here SpectacularAI/nerfstudio@bd23489 (works fine with #97). My argument is that the more stuff is built on top of the current API with separate and redundant "projmat" + fx,fy,cx,cy, the more difficult it becomes to simplify it. I now remembered/realized the situation with the redundant API is worse than I described earlier: "projmat" is actually not a "projection matrix" in any standard sense but a model-view-projection matrix, adding another layer of confusion). This complications caused by this API are clearly visible in this PR: why you need to compute the "projection matrix" gradient for pose optimization in the first place is because the parameter known as projmat is set to Without the |
I gotta say this makes a lot of sense. Now that I think of it, this would cause the gradient for |
Closing this since the 1.0 version includes more exact gradients I believe |
project_gaussians_backward_kernel
forviewmat
andprojmat
examples/test_pose_grad.py
to test pose gradient update. The script interface is the same assimple_trainer.py
: