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

Merging changes from the hilti challenge #515

Closed
wants to merge 164 commits into from
Closed

Conversation

ayushbaid
Copy link
Contributor

No description provided.

Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

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

Awesome. I flagged what I could. Would be good to have report before merging.

gtsfm/averaging/translation/averaging_1dsfm.py Outdated Show resolved Hide resolved
gtsfm/averaging/translation/averaging_1dsfm.py Outdated Show resolved Hide resolved
gtsfm/bundle/bundle_adjustment.py Show resolved Hide resolved
gtsfm/bundle/bundle_adjustment.py Outdated Show resolved Hide resolved
gtsfm/bundle/bundle_adjustment.py Outdated Show resolved Hide resolved
gtsfm/frontend/inlier_support_processor.py Outdated Show resolved Hide resolved
gtsfm/loader/loader_base.py Outdated Show resolved Hide resolved
gtsfm/two_view_estimator.py Show resolved Hide resolved
gtsfm/utils/metrics.py Outdated Show resolved Hide resolved
gtsfm/utils/metrics.py Show resolved Hide resolved
Copy link
Collaborator

@akshay-krishnan akshay-krishnan left a comment

Choose a reason for hiding this comment

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

This is going to be huge!

gtsfm/averaging/rotation/rotation_averaging_base.py Outdated Show resolved Hide resolved
gtsfm/averaging/rotation/rotation_averaging_base.py Outdated Show resolved Hide resolved
) -> BetweenFactorPose3s:
"""Create between factors from the priors on relative poses."""
between_factors = BetweenFactorPose3s()
noise_model = gtsam.noiseModel.Isotropic.Sigma(POSE3_DOF, PRIOR_SIGMA)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why don't we use the covariance now? (i.e address your TODO?)

another nit: the POSE3_DOF is probably overkill. It's something that will never change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we did this somewhere, so you can reuse that code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting convergence issues with Shonan if I used priors from Bayesian ICP. So I was hardcoding it. What should we do now as a feature introduction to master?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this Shonan specific? Were you getting good results in BA or TA?

If all of them need hardcoding, we can do that in the loader. One of them needing it is weird, maybe the other hardcoded values can be changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the main problem here is not the convergence issue, but the noise model. We cannot accept a full covariance matrix in the Shonan averaging. We need to address the TODO on the next line.

Copy link
Collaborator

@akshay-krishnan akshay-krishnan Jun 27, 2022

Choose a reason for hiding this comment

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

This is a pending comment from an old review, please ignore if fixed:

I remember Frank suggested using an isotropic noise model with a Sigma which is an average of the diagonal elements. Not sure how that works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed

gtsfm/averaging/rotation/shonan.py Show resolved Hide resolved
gtsfm/retriever/rig_retriever.py Show resolved Hide resolved
Comment on lines +59 to +60
REACT_METRICS_PATH = BASE_PATH / "rtf_vis_tool" / "src" / "result_metrics"
REACT_RESULTS_PATH = BASE_PATH / "rtf_vis_tool" / "public" / "results"
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we remove this altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think Frank was talking about some student who will pick up the JS work again. So lets keep it for the time being.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, but isnt it the same data that we save in both results_path and react_metrics_path ? Do we need this duplication?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remember there was some need for this because the viz tool could not access the parent of the root folder.

gtsfm/scene_optimizer.py Outdated Show resolved Hide resolved

def save_gtsfm_data(image_graph: List[Delayed], ba_input_graph: Delayed, ba_output_graph: Delayed) -> List[Delayed]:
"""Saves the Gtsfm data before and after bundle adjustment.
aligned_ba_input = ba_input.align_via_Sim3_to_poses(gt_poses)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this duplicated when we compute metrics somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its aligned in a different function. We do align it in the BundleAdjustmentOptimizer::evaluate, but that aligned GtsfmData objects are not returned.

Copy link
Collaborator

Choose a reason for hiding this comment

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

was this the reason why we were aligning ba_input in the other TODO comment? Its pretty expensive so we should only do it once I think

gtsfm/utils/metrics.py Show resolved Hide resolved
@travisdriver
Copy link
Collaborator

Is there any way to break this PR up into smaller ones?

@dellaert
Copy link
Member

dellaert commented Jun 8, 2022

Is there any way to break this PR up into smaller ones?

Yes, obviously there is, but we discussed and decided to do it this way.

Copy link
Collaborator

@akshay-krishnan akshay-krishnan left a comment

Choose a reason for hiding this comment

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

nice work! we're getting closer, I'm not going to add new comments, some of my old ones are not yet resolved.

) -> BetweenFactorPose3s:
"""Create between factors from the priors on relative poses."""
between_factors = BetweenFactorPose3s()
noise_model = gtsam.noiseModel.Isotropic.Sigma(POSE3_DOF, PRIOR_SIGMA)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this Shonan specific? Were you getting good results in BA or TA?

If all of them need hardcoding, we can do that in the loader. One of them needing it is weird, maybe the other hardcoded values can be changed?

gtsfm/averaging/rotation/shonan.py Outdated Show resolved Hide resolved

# Modified for using both fastlio and gtsfm TUM files
# If you already have matplotlib, scipy and numpy, this will need an additional
# pip install evo==1.13.5
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure. I originally put in it in the evaluation directory above gtsfm/ directory, which is currently empty, because it is not part of gtsfm.

Or we could also move it to 3rdparty.

gtsfm/loader/hilti_loader.py Show resolved Hide resolved
gtsfm/multi_view_optimizer.py Show resolved Hide resolved
Comment on lines 148 to 149
# TODO(Frank): Why would we do this here? But maybe we should simply fix align_via_Sim3_to_poses
# ba_input_graph = dask.delayed(ba_input_graph.align_via_Sim3_to_poses)(gt_wTi_list)
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you check who consumes ba_input? and whether they expect it to be aligned to GT? is the output aligned to GT?

Comment on lines +59 to +60
REACT_METRICS_PATH = BASE_PATH / "rtf_vis_tool" / "src" / "result_metrics"
REACT_RESULTS_PATH = BASE_PATH / "rtf_vis_tool" / "public" / "results"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, but isnt it the same data that we save in both results_path and react_metrics_path ? Do we need this duplication?


def save_gtsfm_data(image_graph: List[Delayed], ba_input_graph: Delayed, ba_output_graph: Delayed) -> List[Delayed]:
"""Saves the Gtsfm data before and after bundle adjustment.
aligned_ba_input = ba_input.align_via_Sim3_to_poses(gt_poses)
Copy link
Collaborator

Choose a reason for hiding this comment

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

was this the reason why we were aligning ba_input in the other TODO comment? Its pretty expensive so we should only do it once I think

@akshay-krishnan
Copy link
Collaborator

@ayushbaid we can do this in another PR if we want to submit this one soon: we can remove the "augmentation" logic in TA after we have a release with borglab/gtsam#1224.

Copy link
Collaborator

@akshay-krishnan akshay-krishnan left a comment

Choose a reason for hiding this comment

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

Looks like all comments have been resolved. Just need to fix the CI now.

) -> BetweenFactorPose3s:
"""Create between factors from the priors on relative poses."""
between_factors = BetweenFactorPose3s()
noise_model = gtsam.noiseModel.Isotropic.Sigma(POSE3_DOF, PRIOR_SIGMA)
Copy link
Collaborator

@akshay-krishnan akshay-krishnan Jun 27, 2022

Choose a reason for hiding this comment

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

This is a pending comment from an old review, please ignore if fixed:

I remember Frank suggested using an isotropic noise model with a Sigma which is an average of the diagonal elements. Not sure how that works.


# Modified for using both fastlio and gtsfm TUM files
# If you already have matplotlib, scipy and numpy, this will need an additional
# pip install evo==1.13.5
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we are not going to use this often, no need to depend on evo. Feel free to mark this resolved.

@dellaert
Copy link
Member

Still 2 CI fails?


def read_fastlio_result(poses_txt_path: str) -> Tuple[List[Pose3], np.ndarray]:
"""
Read FastLIO result
Copy link
Collaborator

Choose a reason for hiding this comment

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

@ayushbaid can we update this docstring to the style guide when you get a chance?

return Pose3(pose_rotation, pose_translation)


def create_initial_estimate(poses: List[Pose3]):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add the return type hint here?

EXP07_PATH = DATA_ROOT_PATH / "exp07"


def pose_of_vector(pose_vector):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add the return type hint here?

Dict[Tuple[int, int], Optional[Unit3]],
Dict[Tuple[int, int], np.ndarray],
Dict[int, Tuple[int, int]],
]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

@ayushbaid do you mind adding the return type hint here?

use_cuda (optional): Use CUDA (GPU) for inference. Defaults to True.
use_outdoor_model (optional): Use the outdoor weights for SuperGlue network. Defaults to True.
init_model_in_constructor (optional): Initialize the model with weights in the constructor instead of the
`match` function. This setting is recommended when we are not using
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the formatting got messed up here @ayushbaid ?

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.

5 participants