Skip to content
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 non-trainable camera indices to CameraOptimizer #2080

Merged
merged 5 commits into from
Jun 18, 2023

Conversation

maturk
Copy link
Collaborator

@maturk maturk commented Jun 15, 2023

Here I added the possibility for a user to manually tell the Camera Optimizer not to train certain camera indices. This is needed when you know prior that only certain indices should be trained in the camera training_dataset.

@@ -121,11 +123,13 @@ def forward(
outputs.append(exp_map_SE3(self.pose_adjustment[indices, :]))
else:
assert_never(self.config.mode)
# Detach non-trainable indices by setting to identity transform
if self.non_trainable_camera_indices is not None:
outputs[0][self.non_trainable_camera_indices] = torch.eye(4)[:3, :4].to(self.device)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create on device
torch.eye(4, device=self.device)

@kerrj
Copy link
Collaborator

kerrj commented Jun 15, 2023

LGTM with Matt's change, useful in robotics when you want to prevent the coord frame from drifting too much thru optimization. I wonder if eventually it could be good to optionally input a covariance matrix for each camera, then you can even have a per-camera confidence :). Not sure how you'd incorporate that into the optimization, but maybe just some simple regularization like weighting loss higher on lower confidence cameras

@maturk
Copy link
Collaborator Author

maturk commented Jun 16, 2023

Regarding the camera optimizer, on the top of the file it says Pose and Intrinsics Optimizers but there is no intrinsics optimization currently right? I might look into that as well since I think I will need it...

@kerrj
Copy link
Collaborator

kerrj commented Jun 17, 2023

Yes there is no intrinsic optimization. We're also thinking about refactoring camera optimization to move it out of the datamanager and into the Model, since this allows more natural development of different methods (BARF etc), and also would help speed up dataloading (right now ray generation cannot be parallelized because gradients need to flow from model to datamanager). Might be good to keep this in mind, and if you have thoughts on a refactor we'd love to hear them too

Copy link
Collaborator

@kerrj kerrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tancik tancik enabled auto-merge (squash) June 18, 2023 16:49
@tancik tancik merged commit e0e66ce into nerfstudio-project:main Jun 18, 2023
4 checks passed
lucasthahn pushed a commit to TNE-ai/nerfstudio that referenced this pull request Jun 20, 2023
…ct#2080)

* add non-trainable indices to camera optimizer

* improve comment

* create on device

---------

Co-authored-by: Matthew Tancik <tancik@berkeley.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants