Update README.md
Browse files
README.md
CHANGED
|
@@ -1,199 +1,158 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
## Model Details
|
| 13 |
-
|
| 14 |
-
### Model Description
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
This
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
<!-- Provide the basic links for the model. -->
|
| 31 |
|
| 32 |
-
- **Repository:** [More Information Needed]
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
-
|
| 36 |
-
## Uses
|
| 37 |
-
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 43 |
-
|
| 44 |
-
[More Information Needed]
|
| 45 |
-
|
| 46 |
-
### Downstream Use [optional]
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
|
| 66 |
-
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
| 69 |
|
| 70 |
## How to Get Started with the Model
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
[More Information Needed]
|
| 75 |
|
| 76 |
## Training Details
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
#### Training Hyperparameters
|
| 94 |
|
| 95 |
-
- **Training regime:**
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
|
| 115 |
-
####
|
| 116 |
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
|
| 173 |
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
|
| 175 |
**BibTeX:**
|
| 176 |
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
|
| 197 |
-
## Model Card
|
| 198 |
|
| 199 |
-
[
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
license: other
|
| 4 |
---
|
| 5 |
|
| 6 |
+
# LightGlue
|
| 7 |
|
| 8 |
+
The LightGlue model was proposed
|
| 9 |
+
in [LightGlue: Local Feature Matching at Light Speed](http://arxiv.org/abs/2306.13643) by Philipp Lindenberger, Paul-Edouard Sarlin and Marc Pollefeys.
|
| 10 |
|
| 11 |
+
This model consists of matching two sets of interest points detected in an image. Paired with the
|
| 12 |
+
[SuperPoint model](https://huggingface.co/magic-leap-community/superpoint), it can be used to match two images and
|
| 13 |
+
estimate the pose between them. This model is useful for tasks such as image matching, homography estimation, etc.
|
| 14 |
|
| 15 |
+
The abstract from the paper is the following :
|
| 16 |
+
We introduce LightGlue, a deep neural network that learns to match local features across images. We revisit multiple
|
| 17 |
+
design decisions of SuperGlue, the state of the art in sparse matching, and derive simple but effective improvements.
|
| 18 |
+
Cumulatively, they make LightGlue more efficient – in terms of both memory and computation, more accurate, and much
|
| 19 |
+
easier to train. One key property is that LightGlue is adaptive to the difficulty of the problem: the inference is
|
| 20 |
+
much faster on image pairs that are intuitively easy to match, for example because of a larger visual overlap or
|
| 21 |
+
limited appearance change. This opens up exciting prospects for deploying deep matchers in latency-sensitive
|
| 22 |
+
applications like 3D reconstruction. The code and trained models are publicly available at [github.com/cvg/LightGlue](github.com/cvg/LightGlue).
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
<img src="https://raw.githubusercontent.com/cvg/LightGlue/main/assets/easy_hard.jpg" alt="drawing" width="800"/>
|
| 26 |
|
| 27 |
+
This model was contributed by [stevenbucaille](https://huggingface.co/stevenbucaille).
|
| 28 |
+
The original code can be found [here](https://github.com/cvg/LightGlue).
|
| 29 |
|
| 30 |
+
## Demo notebook
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
A demo notebook showcasing inference + visualization with LightGlue can be found [TBD]().
|
|
|
|
|
|
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
## Model Details
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
### Model Description
|
| 38 |
|
| 39 |
+
LightGlue is a neural network that matches two sets of local features by jointly finding correspondences and rejecting non-matchable points.
|
| 40 |
+
Building on the success of SuperGlue, this model has the ability to introspect the confidence of its own predictions. It adapts the amount of
|
| 41 |
+
computation to the difficulty of each image pair to match. Both its depth and width are adaptive :
|
| 42 |
+
1. the inference can stop at an early layer if all predictions are ready
|
| 43 |
+
2. points that are deemed not matchable are discarded early from further steps.
|
| 44 |
+
The resulting model, LightGlue, is finally faster, more accurate, and easier to train than the long-unrivaled SuperGlue.
|
| 45 |
|
| 46 |
+
<img src="https://cdn-uploads.huggingface.co/production/uploads/632885ba1558dac67c440aa8/ILpGyHuWwK2M9Bz0LmZLh.png" alt="drawing" width="1000"/>
|
| 47 |
|
| 48 |
+
- **Developed by:** ETH Zurich - Computer Vision and Geometry Lab
|
| 49 |
+
- **Model type:** Image Matching
|
| 50 |
+
- **License:** ACADEMIC OR NON-PROFIT ORGANIZATION NONCOMMERCIAL RESEARCH USE ONLY (implied by the use of SuperPoint as its keypoint detector)
|
| 51 |
|
| 52 |
+
### Model Sources
|
| 53 |
|
| 54 |
+
<!-- Provide the basic links for the model. -->
|
| 55 |
|
| 56 |
+
- **Repository:** https://github.com/cvg/LightGlue
|
| 57 |
+
- **Paper:** http://arxiv.org/abs/2306.13643
|
| 58 |
+
- **Demo:** https://colab.research.google.com/github/cvg/LightGlue/blob/main/demo.ipynb
|
| 59 |
|
| 60 |
+
## Uses
|
| 61 |
|
| 62 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 63 |
|
| 64 |
+
### Direct Use
|
| 65 |
|
| 66 |
+
LightGlue is designed for feature matching and pose estimation tasks in computer vision. It can be applied to a variety of multiple-view
|
| 67 |
+
geometry problems and can handle challenging real-world indoor and outdoor environments. However, it may not perform well on tasks that
|
| 68 |
+
require different types of visual understanding, such as object detection or image classification.
|
| 69 |
|
| 70 |
## How to Get Started with the Model
|
| 71 |
|
| 72 |
+
Here is a quick example of using the model. Since this model is an image matching model, it requires pairs of images to be matched.
|
| 73 |
+
The raw outputs contain the list of keypoints detected by the keypoint detector as well as the list of matches with their corresponding
|
| 74 |
+
matching scores.
|
| 75 |
+
```python
|
| 76 |
+
from transformers import AutoImageProcessor, AutoModel
|
| 77 |
+
import torch
|
| 78 |
+
from PIL import Image
|
| 79 |
+
import requests
|
| 80 |
+
|
| 81 |
+
url_image1 = "https://raw.githubusercontent.com/magicleap/SuperGluePretrainedNetwork/refs/heads/master/assets/phototourism_sample_images/united_states_capitol_98169888_3347710852.jpg"
|
| 82 |
+
image1 = Image.open(requests.get(url_image1, stream=True).raw)
|
| 83 |
+
url_image2 = "https://raw.githubusercontent.com/magicleap/SuperGluePretrainedNetwork/refs/heads/master/assets/phototourism_sample_images/united_states_capitol_26757027_6717084061.jpg"
|
| 84 |
+
image2 = Image.open(requests.get(url_image2, stream=True).raw)
|
| 85 |
+
|
| 86 |
+
images = [image1, image2]
|
| 87 |
+
|
| 88 |
+
processor = AutoImageProcessor.from_pretrained("stevenbucaille/lightglue_superpoint")
|
| 89 |
+
model = AutoModel.from_pretrained("stevenbucaille/lightglue_superpoint")
|
| 90 |
+
|
| 91 |
+
inputs = processor(images, return_tensors="pt")
|
| 92 |
+
with torch.no_grad():
|
| 93 |
+
outputs = model(**inputs)
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
You can use the `post_process_keypoint_matching` method from the `LightGlueImageProcessor` to get the keypoints and matches in a readable format:
|
| 97 |
+
```python
|
| 98 |
+
image_sizes = [[(image.height, image.width) for image in images]]
|
| 99 |
+
outputs = processor.post_process_keypoint_matching(outputs, image_sizes, threshold=0.2)
|
| 100 |
+
for i, output in enumerate(outputs):
|
| 101 |
+
print("For the image pair", i)
|
| 102 |
+
for keypoint0, keypoint1, matching_score in zip(
|
| 103 |
+
output["keypoints0"], output["keypoints1"], output["matching_scores"]
|
| 104 |
+
):
|
| 105 |
+
print(
|
| 106 |
+
f"Keypoint at coordinate {keypoint0.numpy()} in the first image matches with keypoint at coordinate {keypoint1.numpy()} in the second image with a score of {matching_score}."
|
| 107 |
+
)
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
You can visualize the matches between the images by providing the original images as well as the outputs to this method:
|
| 111 |
+
```python
|
| 112 |
+
processor.plot_keypoint_matching(images, outputs)
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+

|
| 116 |
|
|
|
|
| 117 |
|
| 118 |
## Training Details
|
| 119 |
|
| 120 |
+
LightGlue is trained on large annotated datasets for pose estimation, enabling it to learn priors for pose estimation and reason about the 3D scene.
|
| 121 |
+
The training data consists of image pairs with ground truth correspondences and unmatched keypoints derived from ground truth poses and depth maps.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
+
LightGlue follows the supervised training setup of SuperGlue. It is first pre-trained with synthetic homographies sampled from 1M images.
|
| 124 |
+
Such augmentations provide full and noise-free supervision but require careful tuning. LightGlue is then fine-tuned with the MegaDepth dataset,
|
| 125 |
+
which includes 1M crowd-sourced images depicting 196 tourism landmarks, with camera calibration and poses recovered by SfM and
|
| 126 |
+
dense depth by multi-view stereo.
|
| 127 |
|
| 128 |
#### Training Hyperparameters
|
| 129 |
|
| 130 |
+
- **Training regime:** fp32
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
+
#### Speeds, Sizes, Times
|
| 133 |
|
| 134 |
+
LightGlue is designed to be efficient and runs in real-time on a modern GPU. A forward pass takes approximately 44 milliseconds (22 FPS) for an image pair.
|
| 135 |
+
The model has 13.7 million parameters, making it relatively compact compared to some other deep learning models.
|
| 136 |
+
The inference speed of LightGlue is suitable for real-time applications and can be readily integrated into
|
| 137 |
+
modern Simultaneous Localization and Mapping (SLAM) or Structure-from-Motion (SfM) systems.
|
| 138 |
|
| 139 |
+
## Citation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 142 |
|
| 143 |
**BibTeX:**
|
| 144 |
|
| 145 |
+
```bibtex
|
| 146 |
+
@inproceedings{lindenberger2023lightglue,
|
| 147 |
+
author = {Philipp Lindenberger and
|
| 148 |
+
Paul-Edouard Sarlin and
|
| 149 |
+
Marc Pollefeys},
|
| 150 |
+
title = {{LightGlue: Local Feature Matching at Light Speed}},
|
| 151 |
+
booktitle = {ICCV},
|
| 152 |
+
year = {2023}
|
| 153 |
+
}
|
| 154 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
+
## Model Card Authors
|
| 157 |
|
| 158 |
+
[Steven Bucaille](https://github.com/sbucaille)
|