IbrahimHasani commited on
Commit
59fdcbd
1 Parent(s): f85a444

Upload 95 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. SuperGluePretrainedNetwork/.gitignore +3 -0
  3. SuperGluePretrainedNetwork/LICENSE +48 -0
  4. SuperGluePretrainedNetwork/README.md +388 -0
  5. SuperGluePretrainedNetwork/assets/freiburg_matches.gif +3 -0
  6. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847980.722988.png +0 -0
  7. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847981.726650.png +0 -0
  8. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847982.730674.png +0 -0
  9. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847983.738736.png +0 -0
  10. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847984.743352.png +0 -0
  11. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847985.746954.png +0 -0
  12. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847986.762616.png +0 -0
  13. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847987.758741.png +0 -0
  14. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847988.769740.png +0 -0
  15. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847989.802890.png +0 -0
  16. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847990.810771.png +0 -0
  17. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847991.814748.png +0 -0
  18. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847992.818723.png +0 -0
  19. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847993.826735.png +0 -0
  20. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847994.866828.png +0 -0
  21. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847995.870641.png +0 -0
  22. SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847996.874766.png +0 -0
  23. SuperGluePretrainedNetwork/assets/indoor_evaluation.png +0 -0
  24. SuperGluePretrainedNetwork/assets/indoor_matches.png +0 -0
  25. SuperGluePretrainedNetwork/assets/magicleap.png +0 -0
  26. SuperGluePretrainedNetwork/assets/megadepth_train_scenes.txt +153 -0
  27. SuperGluePretrainedNetwork/assets/megadepth_validation_scenes.txt +36 -0
  28. SuperGluePretrainedNetwork/assets/outdoor_matches.png +0 -0
  29. SuperGluePretrainedNetwork/assets/phototourism_sample_images/london_bridge_19481797_2295892421.jpg +0 -0
  30. SuperGluePretrainedNetwork/assets/phototourism_sample_images/london_bridge_49190386_5209386933.jpg +0 -0
  31. SuperGluePretrainedNetwork/assets/phototourism_sample_images/london_bridge_78916675_4568141288.jpg +0 -0
  32. SuperGluePretrainedNetwork/assets/phototourism_sample_images/london_bridge_94185272_3874562886.jpg +0 -0
  33. SuperGluePretrainedNetwork/assets/phototourism_sample_images/piazza_san_marco_06795901_3725050516.jpg +0 -0
  34. SuperGluePretrainedNetwork/assets/phototourism_sample_images/piazza_san_marco_15148634_5228701572.jpg +0 -0
  35. SuperGluePretrainedNetwork/assets/phototourism_sample_images/piazza_san_marco_18627786_5929294590.jpg +0 -0
  36. SuperGluePretrainedNetwork/assets/phototourism_sample_images/piazza_san_marco_43351518_2659980686.jpg +0 -0
  37. SuperGluePretrainedNetwork/assets/phototourism_sample_images/piazza_san_marco_58751010_4849458397.jpg +0 -0
  38. SuperGluePretrainedNetwork/assets/phototourism_sample_images/st_pauls_cathedral_30776973_2635313996.jpg +0 -0
  39. SuperGluePretrainedNetwork/assets/phototourism_sample_images/st_pauls_cathedral_37347628_10902811376.jpg +0 -0
  40. SuperGluePretrainedNetwork/assets/phototourism_sample_images/united_states_capitol_26757027_6717084061.jpg +0 -0
  41. SuperGluePretrainedNetwork/assets/phototourism_sample_images/united_states_capitol_98169888_3347710852.jpg +0 -0
  42. SuperGluePretrainedNetwork/assets/phototourism_sample_pairs.txt +7 -0
  43. SuperGluePretrainedNetwork/assets/phototourism_test_pairs.txt +0 -0
  44. SuperGluePretrainedNetwork/assets/phototourism_test_pairs_original.txt +0 -0
  45. SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0711_00_frame-001680.jpg +0 -0
  46. SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0711_00_frame-001995.jpg +0 -0
  47. SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0713_00_frame-001320.jpg +0 -0
  48. SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0713_00_frame-002025.jpg +0 -0
  49. SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0721_00_frame-000375.jpg +0 -0
  50. SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0721_00_frame-002745.jpg +0 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ SuperGluePretrainedNetwork/assets/freiburg_matches.gif filter=lfs diff=lfs merge=lfs -text
SuperGluePretrainedNetwork/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ *.pyc
2
+ *.DS_Store
3
+ *.swp
SuperGluePretrainedNetwork/LICENSE ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ SUPERGLUE: LEARNING FEATURE MATCHING WITH GRAPH NEURAL NETWORKS
2
+ SOFTWARE LICENSE AGREEMENT
3
+ ACADEMIC OR NON-PROFIT ORGANIZATION NONCOMMERCIAL RESEARCH USE ONLY
4
+
5
+ BY USING OR DOWNLOADING THE SOFTWARE, YOU ARE AGREEING TO THE TERMS OF THIS LICENSE AGREEMENT. IF YOU DO NOT AGREE WITH THESE TERMS, YOU MAY NOT USE OR DOWNLOAD THE SOFTWARE.
6
+
7
+ This is a license agreement ("Agreement") between your academic institution or non-profit organization or self (called "Licensee" or "You" in this Agreement) and Magic Leap, Inc. (called "Licensor" in this Agreement). All rights not specifically granted to you in this Agreement are reserved for Licensor.
8
+
9
+ RESERVATION OF OWNERSHIP AND GRANT OF LICENSE:
10
+ Licensor retains exclusive ownership of any copy of the Software (as defined below) licensed under this Agreement and hereby grants to Licensee a personal, non-exclusive, non-transferable license to use the Software for noncommercial research purposes, without the right to sublicense, pursuant to the terms and conditions of this Agreement. As used in this Agreement, the term "Software" means (i) the actual copy of all or any portion of code for program routines made accessible to Licensee by Licensor pursuant to this Agreement, inclusive of backups, updates, and/or merged copies permitted hereunder or subsequently supplied by Licensor, including all or any file structures, programming instructions, user interfaces and screen formats and sequences as well as any and all documentation and instructions related to it, and (ii) all or any derivatives and/or modifications created or made by You to any of the items specified in (i).
11
+
12
+ CONFIDENTIALITY: Licensee acknowledges that the Software is proprietary to Licensor, and as such, Licensee agrees to receive all such materials in confidence and use the Software only in accordance with the terms of this Agreement. Licensee agrees to use reasonable effort to protect the Software from unauthorized use, reproduction, distribution, or publication.
13
+
14
+ COPYRIGHT: The Software is owned by Licensor and is protected by United States copyright laws and applicable international treaties and/or conventions.
15
+
16
+ PERMITTED USES: The Software may be used for your own noncommercial internal research purposes. You understand and agree that Licensor is not obligated to implement any suggestions and/or feedback you might provide regarding the Software, but to the extent Licensor does so, you are not entitled to any compensation related thereto.
17
+
18
+ DERIVATIVES: You may create derivatives of or make modifications to the Software, however, You agree that all and any such derivatives and modifications will be owned by Licensor and become a part of the Software licensed to You under this Agreement. You may only use such derivatives and modifications for your own noncommercial internal research purposes, and you may not otherwise use, distribute or copy such derivatives and modifications in violation of this Agreement.
19
+
20
+ BACKUPS: If Licensee is an organization, it may make that number of copies of the Software necessary for internal noncommercial use at a single site within its organization provided that all information appearing in or on the original labels, including the copyright and trademark notices are copied onto the labels of the copies.
21
+
22
+ USES NOT PERMITTED: You may not distribute, copy or use the Software except as explicitly permitted herein. Licensee has not been granted any trademark license as part of this Agreement and may not use the name or mark "Magic Leap" or any renditions thereof without the prior written permission of Licensor.
23
+
24
+ You may not sell, rent, lease, sublicense, lend, time-share or transfer, in whole or in part, or provide third parties access to prior or present versions (or any parts thereof) of the Software.
25
+
26
+ ASSIGNMENT: You may not assign this Agreement or your rights hereunder without the prior written consent of Licensor. Any attempted assignment without such consent shall be null and void.
27
+
28
+ TERM: The term of the license granted by this Agreement is from Licensee's acceptance of this Agreement by downloading the Software or by using the Software until terminated as provided below.
29
+
30
+ The Agreement automatically terminates without notice if you fail to comply with any provision of this Agreement. Licensee may terminate this Agreement by ceasing using the Software. Upon any termination of this Agreement, Licensee will delete any and all copies of the Software. You agree that all provisions which operate to protect the proprietary rights of Licensor shall remain in force should breach occur and that the obligation of confidentiality described in this Agreement is binding in perpetuity and, as such, survives the term of the Agreement.
31
+
32
+ FEE: Provided Licensee abides completely by the terms and conditions of this Agreement, there is no fee due to Licensor for Licensee's use of the Software in accordance with this Agreement.
33
+
34
+ DISCLAIMER OF WARRANTIES: THE SOFTWARE IS PROVIDED "AS-IS" WITHOUT WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE OR OF NON-INFRINGEMENT. LICENSEE BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND RELATED MATERIALS.
35
+
36
+ SUPPORT AND MAINTENANCE: No Software support or training by the Licensor is provided as part of this Agreement.
37
+
38
+ EXCLUSIVE REMEDY AND LIMITATION OF LIABILITY: To the maximum extent permitted under applicable law, Licensor shall not be liable for direct, indirect, special, incidental, or consequential damages or lost profits related to Licensee's use of and/or inability to use the Software, even if Licensor is advised of the possibility of such damage.
39
+
40
+ EXPORT REGULATION: Licensee agrees to comply with any and all applicable U.S. export control laws, regulations, and/or other laws related to embargoes and sanction programs administered by the Office of Foreign Assets Control.
41
+
42
+ SEVERABILITY: If any provision(s) of this Agreement shall be held to be invalid, illegal, or unenforceable by a court or other tribunal of competent jurisdiction, the validity, legality and enforceability of the remaining provisions shall not in any way be affected or impaired thereby.
43
+
44
+ NO IMPLIED WAIVERS: No failure or delay by Licensor in enforcing any right or remedy under this Agreement shall be construed as a waiver of any future or other exercise of such right or remedy by Licensor.
45
+
46
+ GOVERNING LAW: This Agreement shall be construed and enforced in accordance with the laws of the State of Florida without reference to conflict of laws principles. You consent to the personal jurisdiction of the courts of this County and waive their rights to venue outside of Broward County, Florida.
47
+
48
+ ENTIRE AGREEMENT AND AMENDMENTS: This Agreement constitutes the sole and entire agreement between Licensee and Licensor as to the matter set forth herein and supersedes any previous agreements, understandings, and arrangements between the parties relating hereto.
SuperGluePretrainedNetwork/README.md ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <img src="assets/magicleap.png" width="240">
2
+
3
+ ### Research @ Magic Leap (CVPR 2020, Oral)
4
+
5
+ # SuperGlue Inference and Evaluation Demo Script
6
+
7
+ ## Introduction
8
+ SuperGlue is a CVPR 2020 research project done at Magic Leap. The SuperGlue network is a Graph Neural Network combined with an Optimal Matching layer that is trained to perform matching on two sets of sparse image features. This repo includes PyTorch code and pretrained weights for running the SuperGlue matching network on top of [SuperPoint](https://arxiv.org/abs/1712.07629) keypoints and descriptors. Given a pair of images, you can use this repo to extract matching features across the image pair.
9
+
10
+ <p align="center">
11
+ <img src="assets/teaser.png" width="500">
12
+ </p>
13
+
14
+ SuperGlue operates as a "middle-end," performing context aggregation, matching, and filtering in a single end-to-end architecture. For more details, please see:
15
+
16
+ * Full paper PDF: [SuperGlue: Learning Feature Matching with Graph Neural Networks](https://arxiv.org/abs/1911.11763).
17
+
18
+ * Authors: *Paul-Edouard Sarlin, Daniel DeTone, Tomasz Malisiewicz, Andrew Rabinovich*
19
+
20
+ * Website: [psarlin.com/superglue](https://psarlin.com/superglue) for videos, slides, recent updates, and more visualizations.
21
+
22
+ * `hloc`: a new toolbox for visual localization and SfM with SuperGlue, available at [cvg/Hierarchical-Localization](https://github.com/cvg/Hierarchical-Localization/). Winner of 3 CVPR 2020 competitions on localization and image matching!
23
+
24
+ We provide two pre-trained weights files: an indoor model trained on ScanNet data, and an outdoor model trained on MegaDepth data. Both models are inside the [weights directory](./models/weights). By default, the demo will run the **indoor** model.
25
+
26
+ ## Dependencies
27
+ * Python 3 >= 3.5
28
+ * PyTorch >= 1.1
29
+ * OpenCV >= 3.4 (4.1.2.30 recommended for best GUI keyboard interaction, see this [note](#additional-notes))
30
+ * Matplotlib >= 3.1
31
+ * NumPy >= 1.18
32
+
33
+ Simply run the following command: `pip3 install numpy opencv-python torch matplotlib`
34
+
35
+ ## Contents
36
+ There are two main top-level scripts in this repo:
37
+
38
+ 1. `demo_superglue.py` : runs a live demo on a webcam, IP camera, image directory or movie file
39
+ 2. `match_pairs.py`: reads image pairs from files and dumps matches to disk (also runs evaluation if ground truth relative poses are provided)
40
+
41
+ ## Live Matching Demo Script (`demo_superglue.py`)
42
+ This demo runs SuperPoint + SuperGlue feature matching on an anchor image and live image. You can update the anchor image by pressing the `n` key. The demo can read image streams from a USB or IP camera, a directory containing images, or a video file. You can pass all of these inputs using the `--input` flag.
43
+
44
+ ### Run the demo on a live webcam
45
+
46
+ Run the demo on the default USB webcam (ID #0), running on a CUDA GPU if one is found:
47
+
48
+ ```sh
49
+ ./demo_superglue.py
50
+ ```
51
+
52
+ Keyboard control:
53
+
54
+ * `n`: select the current frame as the anchor
55
+ * `e`/`r`: increase/decrease the keypoint confidence threshold
56
+ * `d`/`f`: increase/decrease the match filtering threshold
57
+ * `k`: toggle the visualization of keypoints
58
+ * `q`: quit
59
+
60
+ Run the demo on 320x240 images running on the CPU:
61
+
62
+ ```sh
63
+ ./demo_superglue.py --resize 320 240 --force_cpu
64
+ ```
65
+
66
+ The `--resize` flag can be used to resize the input image in three ways:
67
+
68
+ 1. `--resize` `width` `height` : will resize to exact `width` x `height` dimensions
69
+ 2. `--resize` `max_dimension` : will resize largest input image dimension to `max_dimension`
70
+ 3. `--resize` `-1` : will not resize (i.e. use original image dimensions)
71
+
72
+ The default will resize images to `640x480`.
73
+
74
+ ### Run the demo on a directory of images
75
+
76
+ The `--input` flag also accepts a path to a directory. We provide a directory of sample images from a sequence. To run the demo on the directory of images in `freiburg_sequence/` on a headless server (will not display to the screen) and write the output visualization images to `dump_demo_sequence/`:
77
+
78
+ ```sh
79
+ ./demo_superglue.py --input assets/freiburg_sequence/ --output_dir dump_demo_sequence --resize 320 240 --no_display
80
+ ```
81
+
82
+ You should see this output on the sample Freiburg-TUM RGBD sequence:
83
+
84
+ <img src="assets/freiburg_matches.gif" width="560">
85
+
86
+ The matches are colored by their predicted confidence in a jet colormap (Red: more confident, Blue: less confident).
87
+
88
+ ### Additional useful command line parameters
89
+ * Use `--image_glob` to change the image file extension (default: `*.png`, `*.jpg`, `*.jpeg`).
90
+ * Use `--skip` to skip intermediate frames (default: `1`).
91
+ * Use `--max_length` to cap the total number of frames processed (default: `1000000`).
92
+ * Use `--show_keypoints` to visualize the detected keypoints (default: `False`).
93
+
94
+ ## Run Matching+Evaluation (`match_pairs.py`)
95
+
96
+ This repo also contains a script `match_pairs.py` that runs the matching from a list of image pairs. With this script, you can:
97
+
98
+ * Run the matcher on a set of image pairs (no ground truth needed)
99
+ * Visualize the keypoints and matches, based on their confidence
100
+ * Evaluate and visualize the match correctness, if the ground truth relative poses and intrinsics are provided
101
+ * Save the keypoints, matches, and evaluation results for further processing
102
+ * Collate evaluation results over many pairs and generate result tables
103
+
104
+ ### Matches only mode
105
+
106
+ The simplest usage of this script will process the image pairs listed in a given text file and dump the keypoints and matches to compressed numpy `npz` files. We provide the challenging ScanNet pairs from the main paper in `assets/example_indoor_pairs/`. Running the following will run SuperPoint + SuperGlue on each image pair, and dump the results to `dump_match_pairs/`:
107
+
108
+ ```sh
109
+ ./match_pairs.py
110
+ ```
111
+
112
+ The resulting `.npz` files can be read from Python as follows:
113
+
114
+ ```python
115
+ >>> import numpy as np
116
+ >>> path = 'dump_match_pairs/scene0711_00_frame-001680_scene0711_00_frame-001995_matches.npz'
117
+ >>> npz = np.load(path)
118
+ >>> npz.files
119
+ ['keypoints0', 'keypoints1', 'matches', 'match_confidence']
120
+ >>> npz['keypoints0'].shape
121
+ (382, 2)
122
+ >>> npz['keypoints1'].shape
123
+ (391, 2)
124
+ >>> npz['matches'].shape
125
+ (382,)
126
+ >>> np.sum(npz['matches']>-1)
127
+ 115
128
+ >>> npz['match_confidence'].shape
129
+ (382,)
130
+ ```
131
+
132
+ For each keypoint in `keypoints0`, the `matches` array indicates the index of the matching keypoint in `keypoints1`, or `-1` if the keypoint is unmatched.
133
+
134
+ ### Visualization mode
135
+
136
+ You can add the flag `--viz` to dump image outputs which visualize the matches:
137
+
138
+ ```sh
139
+ ./match_pairs.py --viz
140
+ ```
141
+
142
+ You should see images like this inside of `dump_match_pairs/` (or something very close to it, see this [note](#a-note-on-reproducibility)):
143
+
144
+ <img src="assets/indoor_matches.png" width="560">
145
+
146
+ The matches are colored by their predicted confidence in a jet colormap (Red: more confident, Blue: less confident).
147
+
148
+ ### Evaluation mode
149
+
150
+ You can also estimate the pose using RANSAC + Essential Matrix decomposition and evaluate it if the ground truth relative poses and intrinsics are provided in the input `.txt` files. Each `.txt` file contains three key ground truth matrices: a 3x3 intrinsics matrix of image0: `K0`, a 3x3 intrinsics matrix of image1: `K1` , and a 4x4 matrix of the relative pose extrinsics `T_0to1`.
151
+
152
+ To run the evaluation on the sample set of images (by default reading `assets/scannet_sample_pairs_with_gt.txt`), you can run:
153
+
154
+ ```sh
155
+ ./match_pairs.py --eval
156
+ ```
157
+
158
+
159
+ Since you enabled `--eval`, you should see collated results printed to the terminal. For the example images provided, you should get the following numbers (or something very close to it, see this [note](#a-note-on-reproducibility)):
160
+
161
+ ```txt
162
+ Evaluation Results (mean over 15 pairs):
163
+ AUC@5 AUC@10 AUC@20 Prec MScore
164
+ 26.99 48.40 64.47 73.52 19.60
165
+ ```
166
+
167
+ The resulting `.npz` files in `dump_match_pairs/` will now contain scalar values related to the evaluation, computed on the sample images provided. Here is what you should find in one of the generated evaluation files:
168
+
169
+ ```python
170
+ >>> import numpy as np
171
+ >>> path = 'dump_match_pairs/scene0711_00_frame-001680_scene0711_00_frame-001995_evaluation.npz'
172
+ >>> npz = np.load(path)
173
+ >>> print(npz.files)
174
+ ['error_t', 'error_R', 'precision', 'matching_score', 'num_correct', 'epipolar_errors']
175
+ ```
176
+
177
+ You can also visualize the evaluation metrics by running the following command:
178
+
179
+ ```sh
180
+ ./match_pairs.py --eval --viz
181
+ ```
182
+
183
+ You should also now see additional images in `dump_match_pairs/` which visualize the evaluation numbers (or something very close to it, see this [note](#a-note-on-reproducibility)):
184
+
185
+ <img src="assets/indoor_evaluation.png" width="560">
186
+
187
+ The top left corner of the image shows the pose error and number of inliers, while the lines are colored by their epipolar error computed with the ground truth relative pose (red: higher error, green: lower error).
188
+
189
+ ### Running on sample outdoor pairs
190
+
191
+ <details>
192
+ <summary>[Click to expand]</summary>
193
+
194
+ In this repo, we also provide a few challenging Phototourism pairs, so that you can re-create some of the figures from the paper. Run this script to run matching and visualization (no ground truth is provided, see this [note](#reproducing-outdoor-evaluation-final-table)) on the provided pairs:
195
+
196
+ ```sh
197
+ ./match_pairs.py --resize 1600 --superglue outdoor --max_keypoints 2048 --nms_radius 3 --resize_float --input_dir assets/phototourism_sample_images/ --input_pairs assets/phototourism_sample_pairs.txt --output_dir dump_match_pairs_outdoor --viz
198
+ ```
199
+
200
+ You should now image pairs such as these in `dump_match_pairs_outdoor/` (or something very close to it, see this [note](#a-note-on-reproducibility)):
201
+
202
+ <img src="assets/outdoor_matches.png" width="560">
203
+
204
+ </details>
205
+
206
+ ### Recommended settings for indoor / outdoor
207
+
208
+ <details>
209
+ <summary>[Click to expand]</summary>
210
+
211
+ For **indoor** images, we recommend the following settings (these are the defaults):
212
+
213
+ ```sh
214
+ ./match_pairs.py --resize 640 --superglue indoor --max_keypoints 1024 --nms_radius 4
215
+ ```
216
+
217
+ For **outdoor** images, we recommend the following settings:
218
+
219
+ ```sh
220
+ ./match_pairs.py --resize 1600 --superglue outdoor --max_keypoints 2048 --nms_radius 3 --resize_float
221
+ ```
222
+
223
+ You can provide your own list of pairs `--input_pairs` for images contained in `--input_dir`. Images can be resized before network inference with `--resize`. If you are re-running the same evaluation many times, you can use the `--cache` flag to reuse old computation.
224
+ </details>
225
+
226
+ ### Test set pair file format explained
227
+
228
+ <details>
229
+ <summary>[Click to expand]</summary>
230
+
231
+ We provide the list of ScanNet test pairs in `assets/scannet_test_pairs_with_gt.txt` (with ground truth) and Phototourism test pairs `assets/phototourism_test_pairs.txt` (without ground truth) used to evaluate the matching from the paper. Each line corresponds to one pair and is structured as follows:
232
+
233
+ ```
234
+ path_image_A path_image_B exif_rotationA exif_rotationB [KA_0 ... KA_8] [KB_0 ... KB_8] [T_AB_0 ... T_AB_15]
235
+ ```
236
+
237
+ The `path_image_A` and `path_image_B` entries are paths to image A and B, respectively. The `exif_rotation` is an integer in the range [0, 3] that comes from the original EXIF metadata associated with the image, where, 0: no rotation, 1: 90 degree clockwise, 2: 180 degree clockwise, 3: 270 degree clockwise. If the EXIF data is not known, you can just provide a zero here and no rotation will be performed. `KA` and `KB` are the flattened `3x3` matrices of image A and image B intrinsics. `T_AB` is a flattened `4x4` matrix of the extrinsics between the pair.
238
+ </details>
239
+
240
+ ### Reproducing the indoor evaluation on ScanNet
241
+
242
+ <details>
243
+ <summary>[Click to expand]</summary>
244
+
245
+ We provide the groundtruth for ScanNet in our format in the file `assets/scannet_test_pairs_with_gt.txt` for convenience. In order to reproduce similar tables to what was in the paper, you will need to download the dataset (we do not provide the raw test images). To download the ScanNet dataset, do the following:
246
+
247
+ 1. Head to the [ScanNet](https://github.com/ScanNet/ScanNet) github repo to download the ScanNet test set (100 scenes).
248
+ 2. You will need to extract the raw sensor data from the 100 `.sens` files in each scene in the test set using the [SensReader](https://github.com/ScanNet/ScanNet/tree/master/SensReader) tool.
249
+
250
+ Once the ScanNet dataset is downloaded in `~/data/scannet`, you can run the following:
251
+
252
+ ```sh
253
+ ./match_pairs.py --input_dir ~/data/scannet --input_pairs assets/scannet_test_pairs_with_gt.txt --output_dir dump_scannet_test_results --eval
254
+ ```
255
+
256
+ You should get the following table for ScanNet (or something very close to it, see this [note](#a-note-on-reproducibility)):
257
+
258
+ ```txt
259
+ Evaluation Results (mean over 1500 pairs):
260
+ AUC@5 AUC@10 AUC@20 Prec MScore
261
+ 16.12 33.76 51.79 84.37 31.14
262
+ ```
263
+
264
+ </details>
265
+
266
+ ### Reproducing the outdoor evaluation on YFCC
267
+
268
+ <details>
269
+ <summary>[Click to expand]</summary>
270
+
271
+ We provide the groundtruth for YFCC in our format in the file `assets/yfcc_test_pairs_with_gt.txt` for convenience. In order to reproduce similar tables to what was in the paper, you will need to download the dataset (we do not provide the raw test images). To download the YFCC dataset, you can use the [OANet](https://github.com/zjhthu/OANet) repo:
272
+
273
+ ```sh
274
+ git clone https://github.com/zjhthu/OANet
275
+ cd OANet
276
+ bash download_data.sh raw_data raw_data_yfcc.tar.gz 0 8
277
+ tar -xvf raw_data_yfcc.tar.gz
278
+ mv raw_data/yfcc100m ~/data
279
+ ```
280
+
281
+ Once the YFCC dataset is downloaded in `~/data/yfcc100m`, you can run the following:
282
+
283
+ ```sh
284
+ ./match_pairs.py --input_dir ~/data/yfcc100m --input_pairs assets/yfcc_test_pairs_with_gt.txt --output_dir dump_yfcc_test_results --eval --resize 1600 --superglue outdoor --max_keypoints 2048 --nms_radius 3 --resize_float
285
+ ```
286
+
287
+ You should get the following table for YFCC (or something very close to it, see this [note](#a-note-on-reproducibility)):
288
+
289
+ ```txt
290
+ Evaluation Results (mean over 4000 pairs):
291
+ AUC@5 AUC@10 AUC@20 Prec MScore
292
+ 39.02 59.51 75.72 98.72 23.61
293
+ ```
294
+
295
+ </details>
296
+
297
+ ### Reproducing outdoor evaluation on Phototourism
298
+
299
+ <details>
300
+ <summary>[Click to expand]</summary>
301
+
302
+ The Phototourism results shown in the paper were produced using similar data as the test set from the [Image Matching Challenge 2020](https://vision.uvic.ca/image-matching-challenge/), which holds the ground truth data private for the test set. We list the pairs we used in `assets/phototourism_test_pairs.txt`. To reproduce similar numbers on this test set, please submit to the challenge benchmark. While the challenge is still live, we cannot share the test set publically since we want to help maintain the integrity of the challenge.
303
+
304
+ </details>
305
+
306
+ ### Correcting EXIF rotation data in YFCC and Phototourism
307
+
308
+ <details>
309
+ <summary>[Click to expand]</summary>
310
+
311
+ In this repo, we provide manually corrected the EXIF rotation data for the outdoor evaluations on YFCC and Phototourism. For the YFCC dataset we found 7 images with incorrect EXIF rotation flags, resulting in 148 pairs out of 4000 being corrected. For Phototourism, we found 36 images with incorrect EXIF rotation flags, resulting in 212 out of 2200 pairs being corrected.
312
+
313
+ The SuperGlue paper reports the results of SuperGlue **without** the corrected rotations, while the numbers in this README are reported **with** the corrected rotations. We found that our final conclusions from the evaluation still hold with or without the corrected rotations. For backwards compatability, we included the original, uncorrected EXIF rotation data in `assets/phototourism_test_pairs_original.txt` and `assets/yfcc_test_pairs_with_gt_original.txt` respectively.
314
+
315
+ </details>
316
+
317
+ ### Outdoor training / validation scene splits of MegaDepth
318
+
319
+ <details>
320
+ <summary>[Click to expand]</summary>
321
+
322
+ For training and validation of the outdoor model, we used scenes from the [MegaDepth dataset](http://www.cs.cornell.edu/projects/megadepth/). We provide the list of scenes used to train the outdoor model in the `assets/` directory:
323
+
324
+ * Training set: `assets/megadepth_train_scenes.txt`
325
+ * Validation set: `assets/megadepth_validation_scenes.txt`
326
+
327
+ </details>
328
+
329
+ ### A note on reproducibility
330
+
331
+ <details>
332
+ <summary>[Click to expand]</summary>
333
+
334
+ After simplifying the model code and evaluation code and preparing it for release, we made some improvements and tweaks that result in slightly different numbers than what was reported in the paper. The numbers and figures reported in the README were done using Ubuntu 16.04, OpenCV 3.4.5, and PyTorch 1.1.0. Even with matching the library versions, we observed some slight differences across Mac and Ubuntu, which we believe are due to differences in OpenCV's image resize function implementation and randomization of RANSAC.
335
+ </details>
336
+
337
+ ### Creating high-quality PDF visualizations and faster visualization with --fast_viz
338
+
339
+ <details>
340
+ <summary>[Click to expand]</summary>
341
+
342
+ When generating output images with `match_pairs.py`, the default `--viz` flag uses a Matplotlib renderer which allows for the generation of camera-ready PDF visualizations if you additionally use `--viz_extension pdf` instead of the default png extension.
343
+
344
+ ```
345
+ ./match_pairs.py --viz --viz_extension pdf
346
+ ```
347
+
348
+ Alternatively, you might want to save visualization images but have the generation be much faster. You can use the `--fast_viz` flag to use an OpenCV-based image renderer as follows:
349
+
350
+ ```
351
+ ./match_pairs.py --viz --fast_viz
352
+ ```
353
+
354
+ If you would also like an OpenCV display window to preview the results (you must use non-pdf output and use fast_fiz), simply run:
355
+
356
+ ```
357
+ ./match_pairs.py --viz --fast_viz --opencv_display
358
+ ```
359
+
360
+ </details>
361
+
362
+
363
+ ## BibTeX Citation
364
+ If you use any ideas from the paper or code from this repo, please consider citing:
365
+
366
+ ```txt
367
+ @inproceedings{sarlin20superglue,
368
+ author = {Paul-Edouard Sarlin and
369
+ Daniel DeTone and
370
+ Tomasz Malisiewicz and
371
+ Andrew Rabinovich},
372
+ title = {{SuperGlue}: Learning Feature Matching with Graph Neural Networks},
373
+ booktitle = {CVPR},
374
+ year = {2020},
375
+ url = {https://arxiv.org/abs/1911.11763}
376
+ }
377
+ ```
378
+
379
+ ## Additional Notes
380
+ * For the demo, we found that the keyboard interaction works well with OpenCV 4.1.2.30, older versions were less responsive and the newest version had a [OpenCV bug on Mac](https://stackoverflow.com/questions/60032540/opencv-cv2-imshow-is-not-working-because-of-the-qt)
381
+ * We generally do not recommend to run SuperPoint+SuperGlue below 160x120 resolution (QQVGA) and above 2000x1500
382
+ * We do not intend to release the SuperGlue training code.
383
+ * We do not intend to release the SIFT-based or homography SuperGlue models.
384
+
385
+ ## Legal Disclaimer
386
+ Magic Leap is proud to provide its latest samples, toolkits, and research projects on Github to foster development and gather feedback from the spatial computing community. Use of the resources within this repo is subject to (a) the license(s) included herein, or (b) if no license is included, Magic Leap's [Developer Agreement](https://id.magicleap.com/terms/developer), which is available on our [Developer Portal](https://developer.magicleap.com/).
387
+ If you need more, just ask on the [forums](https://forum.magicleap.com/hc/en-us/community/topics)!
388
+ We're thrilled to be part of a well-meaning, friendly and welcoming community of millions.
SuperGluePretrainedNetwork/assets/freiburg_matches.gif ADDED

Git LFS Details

  • SHA256: c7d9e458f625eccbf94e7171218beb6f8c392ca432df3de0ed0a8a2544e13fd6
  • Pointer size: 132 Bytes
  • Size of remote file: 1.43 MB
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847980.722988.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847981.726650.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847982.730674.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847983.738736.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847984.743352.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847985.746954.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847986.762616.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847987.758741.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847988.769740.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847989.802890.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847990.810771.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847991.814748.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847992.818723.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847993.826735.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847994.866828.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847995.870641.png ADDED
SuperGluePretrainedNetwork/assets/freiburg_sequence/1341847996.874766.png ADDED
SuperGluePretrainedNetwork/assets/indoor_evaluation.png ADDED
SuperGluePretrainedNetwork/assets/indoor_matches.png ADDED
SuperGluePretrainedNetwork/assets/magicleap.png ADDED
SuperGluePretrainedNetwork/assets/megadepth_train_scenes.txt ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 0000
2
+ 0001
3
+ 0002
4
+ 0003
5
+ 0004
6
+ 0005
7
+ 0007
8
+ 0008
9
+ 0011
10
+ 0012
11
+ 0013
12
+ 0015
13
+ 0017
14
+ 0020
15
+ 0022
16
+ 0023
17
+ 0026
18
+ 0027
19
+ 0032
20
+ 0033
21
+ 0034
22
+ 0035
23
+ 0036
24
+ 0037
25
+ 0039
26
+ 0041
27
+ 0042
28
+ 0043
29
+ 0044
30
+ 0046
31
+ 0048
32
+ 0049
33
+ 0050
34
+ 0056
35
+ 0057
36
+ 0060
37
+ 0061
38
+ 0062
39
+ 0063
40
+ 0065
41
+ 0067
42
+ 0070
43
+ 0071
44
+ 0076
45
+ 0080
46
+ 0083
47
+ 0086
48
+ 0087
49
+ 0090
50
+ 0092
51
+ 0094
52
+ 0095
53
+ 0098
54
+ 0099
55
+ 0100
56
+ 0101
57
+ 0102
58
+ 0103
59
+ 0104
60
+ 0105
61
+ 0107
62
+ 0115
63
+ 0117
64
+ 0122
65
+ 0130
66
+ 0137
67
+ 0141
68
+ 0143
69
+ 0147
70
+ 0148
71
+ 0149
72
+ 0150
73
+ 0151
74
+ 0156
75
+ 0160
76
+ 0162
77
+ 0176
78
+ 0177
79
+ 0183
80
+ 0189
81
+ 0190
82
+ 0197
83
+ 0200
84
+ 0209
85
+ 0214
86
+ 0224
87
+ 0231
88
+ 0235
89
+ 0237
90
+ 0238
91
+ 0240
92
+ 0243
93
+ 0252
94
+ 0257
95
+ 0258
96
+ 0265
97
+ 0269
98
+ 0275
99
+ 0277
100
+ 0281
101
+ 0290
102
+ 0299
103
+ 0306
104
+ 0307
105
+ 0312
106
+ 0323
107
+ 0326
108
+ 0327
109
+ 0331
110
+ 0335
111
+ 0341
112
+ 0348
113
+ 0360
114
+ 0366
115
+ 0377
116
+ 0380
117
+ 0389
118
+ 0394
119
+ 0402
120
+ 0406
121
+ 0407
122
+ 0411
123
+ 0430
124
+ 0446
125
+ 0455
126
+ 0472
127
+ 0474
128
+ 0476
129
+ 0478
130
+ 0493
131
+ 0494
132
+ 0496
133
+ 0505
134
+ 0559
135
+ 0733
136
+ 0860
137
+ 1017
138
+ 4541
139
+ 5000
140
+ 5001
141
+ 5002
142
+ 5003
143
+ 5004
144
+ 5005
145
+ 5006
146
+ 5007
147
+ 5008
148
+ 5009
149
+ 5010
150
+ 5011
151
+ 5012
152
+ 5013
153
+ 5017
SuperGluePretrainedNetwork/assets/megadepth_validation_scenes.txt ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 0016
2
+ 0047
3
+ 0058
4
+ 0064
5
+ 0121
6
+ 0129
7
+ 0133
8
+ 0168
9
+ 0175
10
+ 0178
11
+ 0181
12
+ 0185
13
+ 0186
14
+ 0204
15
+ 0205
16
+ 0212
17
+ 0217
18
+ 0223
19
+ 0229
20
+ 0271
21
+ 0285
22
+ 0286
23
+ 0294
24
+ 0303
25
+ 0349
26
+ 0387
27
+ 0412
28
+ 0443
29
+ 0482
30
+ 0768
31
+ 1001
32
+ 3346
33
+ 5014
34
+ 5015
35
+ 5016
36
+ 5018
SuperGluePretrainedNetwork/assets/outdoor_matches.png ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/london_bridge_19481797_2295892421.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/london_bridge_49190386_5209386933.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/london_bridge_78916675_4568141288.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/london_bridge_94185272_3874562886.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/piazza_san_marco_06795901_3725050516.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/piazza_san_marco_15148634_5228701572.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/piazza_san_marco_18627786_5929294590.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/piazza_san_marco_43351518_2659980686.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/piazza_san_marco_58751010_4849458397.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/st_pauls_cathedral_30776973_2635313996.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/st_pauls_cathedral_37347628_10902811376.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/united_states_capitol_26757027_6717084061.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_images/united_states_capitol_98169888_3347710852.jpg ADDED
SuperGluePretrainedNetwork/assets/phototourism_sample_pairs.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ london_bridge_78916675_4568141288.jpg london_bridge_19481797_2295892421.jpg
2
+ london_bridge_94185272_3874562886.jpg london_bridge_49190386_5209386933.jpg
3
+ piazza_san_marco_15148634_5228701572.jpg piazza_san_marco_06795901_3725050516.jpg
4
+ piazza_san_marco_43351518_2659980686.jpg piazza_san_marco_06795901_3725050516.jpg
5
+ piazza_san_marco_58751010_4849458397.jpg piazza_san_marco_18627786_5929294590.jpg
6
+ st_pauls_cathedral_37347628_10902811376.jpg st_pauls_cathedral_30776973_2635313996.jpg
7
+ united_states_capitol_98169888_3347710852.jpg united_states_capitol_98169888_3347710852.jpg
SuperGluePretrainedNetwork/assets/phototourism_test_pairs.txt ADDED
The diff for this file is too large to render. See raw diff
 
SuperGluePretrainedNetwork/assets/phototourism_test_pairs_original.txt ADDED
The diff for this file is too large to render. See raw diff
 
SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0711_00_frame-001680.jpg ADDED
SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0711_00_frame-001995.jpg ADDED
SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0713_00_frame-001320.jpg ADDED
SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0713_00_frame-002025.jpg ADDED
SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0721_00_frame-000375.jpg ADDED
SuperGluePretrainedNetwork/assets/scannet_sample_images/scene0721_00_frame-002745.jpg ADDED