Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MPV
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Macalík
MPV
Commits
bf2b4f9b
Commit
bf2b4f9b
authored
1 year ago
by
Dmytro Mishkin
Browse files
Options
Downloads
Patches
Plain Diff
remove tasks from previous year
parent
2ee1aa73
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
assignment_0_3_correspondences_template/matching.py
+0
-51
0 additions, 51 deletions
assignment_0_3_correspondences_template/matching.py
with
0 additions
and
51 deletions
assignment_0_3_correspondences_template/matching.py
+
0
−
51
View file @
bf2b4f9b
...
...
@@ -5,21 +5,6 @@ import torch.nn.functional as F
import
typing
def
match_nn
(
desc1
:
torch
.
Tensor
,
desc2
:
torch
.
Tensor
):
'''
Function, which finds nearest neightbors for each vector in desc1.
Return:
torch.Tensor: indexes of matching descriptors in desc1 and desc2
torch.Tensor: L2 desriptor distance
Shape:
- Input :math:`(B1, D)`, :math:`(B2, D)`
- Output: :math:`(B1, 2)`, :math:`(B1, 1)`
'''
matches_idxs
=
torch
.
arange
(
0
,
desc2
.
size
(
0
)).
view
(
-
1
,
1
).
repeat
(
1
,
2
)
match_dists
=
torch
.
zeros
(
desc2
.
size
(
0
),
1
)
return
matches_idxs
,
match_dists
def
match_snn
(
desc1
:
torch
.
Tensor
,
desc2
:
torch
.
Tensor
,
th
:
float
=
0.8
):
...
...
@@ -38,39 +23,3 @@ def match_snn(desc1: torch.Tensor, desc2: torch.Tensor, th: float = 0.8):
matches_idxs
=
torch
.
arange
(
0
,
desc2
.
size
(
0
)).
view
(
-
1
,
1
).
repeat
(
1
,
2
)
match_dists
=
torch
.
zeros
(
desc2
.
size
(
0
),
1
)
return
matches_idxs
,
match_dists
def
match_mnn
(
desc1
:
torch
.
Tensor
,
desc2
:
torch
.
Tensor
):
'''
Function, which finds mutual nearest neightbors for each vector in desc1 and desc2.
Return:
torch.Tensor: indexes of matching descriptors in desc1 and desc2
torch.Tensor: L2 desriptor distance
Shape:
- Input :math:`(B1, D)`, :math:`(B2, D)`
- Output: :math:`(B3, 2)`, :math:`(B3, 1)` where 0 <= B3 <= min(B1,B2)
'''
matches_idxs
=
torch
.
arange
(
0
,
desc2
.
size
(
0
)).
view
(
-
1
,
1
).
repeat
(
1
,
2
)
match_dists
=
torch
.
zeros
(
desc2
.
size
(
0
),
1
)
return
matches_idxs
,
match_dists
def
match_smnn
(
desc1
:
torch
.
Tensor
,
desc2
:
torch
.
Tensor
,
th
:
float
=
0.8
):
'''
Function, which finds mutual nearest neightbors for each vector in desc1 and desc2,
which satisfy first to second nearest neighbor distance <= th check in both directions.
So, it is intersection of match_mnn(d1,d2), match_snn(d1,d2), match_snn(d2,d1)
Resulting distance ratio should be maximum over over distance ratio in both directions
Return:
torch.Tensor: indexes of matching descriptors in desc1 and desc2
torch.Tensor: L2 desriptor distance ratio 1st to 2nd nearest neighbor
Shape:
- Input :math:`(B1, D)`, :math:`(B2, D)`
- Output: :math:`(B3, 2)`, :math:`(B3, 1)`, where 0 <= B3 <= min(B1, B2)
'''
matches_idxs
=
torch
.
arange
(
0
,
desc2
.
size
(
0
)).
view
(
-
1
,
1
).
repeat
(
1
,
2
)
match_dists
=
torch
.
zeros
(
desc2
.
size
(
0
),
1
)
return
matches_idxs
,
match_dists
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment