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

fixed a minor bug: assign values to a sliced tensor #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions models/gt_matches_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,19 @@ def generate_gt_matches(data: Dict[str, Any],

symmetric_dist = 0.5 * (min_dist0[cross_check_consistent0] + min_dist1[cross_check_consistent1])

gt_matches0[cross_check_consistent0][symmetric_dist > positive_threshold] = IGNORE_INDEX
gt_matches0[cross_check_consistent0][symmetric_dist > negative_threshold] = UNMATCHED_INDEX
gt_matches0_cross = gt_matches0[cross_check_consistent0].clone()
gt_matches1_cross = gt_matches1[cross_check_consistent1].clone()
gt_matches0_uncross = gt_matches0[~cross_check_consistent0].clone()
gt_matches1_uncross = gt_matches1[~cross_check_consistent1].clone()

gt_matches1[cross_check_consistent1][symmetric_dist > positive_threshold] = IGNORE_INDEX
gt_matches1[cross_check_consistent1][symmetric_dist > negative_threshold] = UNMATCHED_INDEX
gt_matches0_cross[symmetric_dist > positive_threshold] = IGNORE_INDEX
gt_matches0_cross[symmetric_dist > negative_threshold] = UNMATCHED_INDEX

gt_matches0[~cross_check_consistent0][min_dist0[~cross_check_consistent0] <= negative_threshold] = IGNORE_INDEX
gt_matches1[~cross_check_consistent1][min_dist1[~cross_check_consistent1] <= negative_threshold] = IGNORE_INDEX
gt_matches1_cross[symmetric_dist > positive_threshold] = IGNORE_INDEX
gt_matches1_cross[symmetric_dist > negative_threshold] = UNMATCHED_INDEX

gt_matches0_uncross[min_dist0[~cross_check_consistent0] <= negative_threshold] = IGNORE_INDEX
gt_matches1_uncross[min_dist1[~cross_check_consistent1] <= negative_threshold] = IGNORE_INDEX

# mutual NN with sym_dist <= pos.th ==> MATCHED
# mutual NN with pos.th < sym_dist <= neg.th ==> IGNORED
Expand All @@ -74,8 +79,13 @@ def generate_gt_matches(data: Dict[str, Any],
gt_matches1[~mask1] = IGNORE_INDEX

# also ignore MATCHED point if its nearest neighbor is invalid
gt_matches0[cross_check_consistent0][~mask1.gather(1, nn_matches0)[cross_check_consistent0]] = IGNORE_INDEX
gt_matches1[cross_check_consistent1][~mask0.gather(1, nn_matches1)[cross_check_consistent1]] = IGNORE_INDEX
gt_matches0_cross[~mask1.gather(1, nn_matches0)[cross_check_consistent0]] = IGNORE_INDEX
gt_matches1_cross[~mask0.gather(1, nn_matches1)[cross_check_consistent1]] = IGNORE_INDEX

# update gt_matches0, gt_matches1
gt_matches0.masked_scatter_(cross_check_consistent0, gt_matches0_cross)
gt_matches1.masked_scatter_(cross_check_consistent1, gt_matches1_cross)


data = {
**data,
Expand Down