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

Add SuperGlue model #29886

Merged
merged 169 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
dfcac01
Initial commit with template code generated by transformers-cli
sbucaille Aug 23, 2023
081efbf
Multiple additions to SuperGlue implementation :
sbucaille Aug 25, 2023
b51ef54
Few changes for SuperGlue
Mar 19, 2024
78ff459
Multiple changes :
Mar 26, 2024
169c77c
Reverted unintentional change
Mar 30, 2024
11389f7
Multiple changes :
Mar 30, 2024
ffd3d76
Moved things in init files
Apr 9, 2024
875c291
Added docs (to be finished depending on the final implementation)
Apr 10, 2024
e0fd6b9
Added necessary imports and some doc
Apr 10, 2024
355e57e
Removed unnecessary import
Apr 10, 2024
38a86b3
Fixed make fix-copies bug and ran it
Apr 10, 2024
186d5f4
Deleted SuperGlueModel
Apr 10, 2024
6237a36
Added SuperGlueImageProcessor
Apr 11, 2024
fb7c58b
Changed SuperGlue to support batching pairs of images and modified Im…
Apr 11, 2024
18e1818
Changed convert_superglue_to_hf.py script to experiment different way…
Apr 11, 2024
33a0774
Added initial tests for SuperGlueImageProcessor
Apr 13, 2024
f516bea
Added AutoModelForImageMatching in missing places and tests
Apr 15, 2024
4d12216
Fixed keypoint_detector_output instructions
Apr 15, 2024
ca54def
Fix style
Apr 15, 2024
113d8bf
Adapted to latest main changes
May 11, 2024
77948ac
Added integration test
May 18, 2024
dd95fdd
Fixed bugs to pass tests
May 18, 2024
006c49a
Added keypoints returned by keypoint detector in the output of SuperGlue
May 18, 2024
7e24e8a
Added doc to SuperGlue
May 19, 2024
6ba3350
SuperGlue returning all attention and hidden states for a fixed numbe…
May 19, 2024
4c1b67d
Make style
May 19, 2024
ff6808e
Changed SuperGlueImageProcessor tests
May 20, 2024
b67ce1b
Revert "SuperGlue returning all attention and hidden states for a fix…
May 20, 2024
0da244f
Added back hidden_states and attentions masked outputs with tests
May 21, 2024
9fda942
Renamed ImageMatching occurences into KeypointMatching
May 21, 2024
f5cacf9
Changed SuperGlueImageProcessor to raise error when batch_size is not…
May 21, 2024
6556963
Added docs and clarity to hidden state and attention grouping function
May 22, 2024
b68ba3d
Fixed some code and done refactoring
May 22, 2024
2120390
Fixed typo in SuperPoint output doc
May 22, 2024
e1810fb
Fixed some of the formatting and variable naming problems
May 26, 2024
774b371
Removed useless function call
May 26, 2024
9a527bb
Removed AutoModelForKeypointMatching
May 26, 2024
c0f9aac
Fixed SuperGlueImageProcessor to only accept paris of images
May 26, 2024
ba6c533
Added more fixes to SuperGlueImageProcessor
May 26, 2024
9adcfa4
Simplified the batching of attention and hidden states
May 26, 2024
a733666
Simplified stack functions
May 26, 2024
2b6f777
Moved attention instructions into class
May 26, 2024
61332fa
Removed unused do_batch_norm argument
May 26, 2024
769d94a
Moved weight initialization to the proper place
May 26, 2024
798f9fe
Replaced deepcopy for instantiation
May 26, 2024
1d7269e
Fixed small bug
May 26, 2024
d40210b
Changed from stevenbucaille to magic-leap repo
May 26, 2024
5920131
Renamed London Bridge images to Tower Bridge
May 26, 2024
a726617
Fixed formatting
May 26, 2024
83a6422
Renamed remaining "london" to "tower"
May 26, 2024
a910b85
Apply suggestions from code review
sbucaille Jun 4, 2024
90fab40
Added AutoModelForKeypointMatching
Jun 4, 2024
d02b8b9
Changed images used in example
Jun 4, 2024
3e94f1f
Several changes to image_processing_superglue and style
Jun 4, 2024
417ce26
Fixed resample type hint
Jun 4, 2024
0d46d64
Changed SuperGlueImageProcessor and added test case for list of 2 images
Jun 4, 2024
b2b7264
Changed list_of_tuples implementation
Jun 8, 2024
dc15c4a
Fix in dummy objects
Jun 8, 2024
00b4e5a
Added normalize_keypoint, log_sinkhorn_iterations and log_optimal_tra…
Jun 8, 2024
1bfd289
Added missing docstring
Jun 8, 2024
fc53366
Apply suggestions from code review
sbucaille Jun 8, 2024
b5cd46d
Apply suggestions from code review
sbucaille Jun 8, 2024
db4507f
Moved forward block at bottom
Jun 8, 2024
866866d
Added docstring to forward method
Jun 8, 2024
8510749
Added docstring to match_image_pair method
Jun 8, 2024
9f269d9
Changed test_model_common_attributes to test_model_get_set_embeddings…
Jun 8, 2024
7173ed8
Removed AutoModelForKeypointMatching
Jun 10, 2024
3d77a20
Removed image fixtures and added load_dataset
Jun 10, 2024
0e4ab19
Added padding of images in SuperGlueImageProcessor
Jun 10, 2024
a794ade
Cleaned up convert_superglue_to_hf script
Jun 14, 2024
10886a6
Added missing docs and fixed unused argument
Jun 14, 2024
6982f80
Fixed SuperGlueImageProcessor tests
Jun 16, 2024
dba1701
Transposed all hidden states from SuperGlue to reflect the standard (…
sbucaille Jun 23, 2024
c6c69fa
Added SuperGlueForKeypointMatching back to modeling_auto
sbucaille Jun 23, 2024
af51f8f
Fixed image processor padding test
sbucaille Jul 10, 2024
1f5df27
Changed SuperGlue docs
sbucaille Jul 11, 2024
d9cd67f
changes:
sbucaille Jul 14, 2024
933b72d
Changes to SuperGlueImageProcessor:
sbucaille Jul 17, 2024
7b5e21d
Formatting changes
sbucaille Jul 17, 2024
ec824b7
Reverted conv1d to linear conversion because of numerical differences
sbucaille Jul 19, 2024
2a95cef
fix: changed some code to be more straightforward (e.g. filtering key…
sbucaille Jul 20, 2024
3e48daf
fix: removed unnecessary test
sbucaille Jul 20, 2024
bdae04c
chore: removed commented code and added back hidden states transposit…
sbucaille Jul 20, 2024
5dcf6f8
chore: changed from "inconsistent" to "ragged" function names as sugg…
sbucaille Sep 4, 2024
9793f4e
docs: applied suggestions
sbucaille Sep 4, 2024
e25ab9d
docs: updated to display matched output
Sep 5, 2024
95fb28f
chore: applied suggestion for check_image_pairs_input function
sbucaille Sep 5, 2024
3e8c974
chore: changed check_image_pairs_input function name to validate_and_…
Sep 5, 2024
7569107
tests: simplified tests for image input format and shapes
Sep 5, 2024
3f79ae4
feat: converted SuperGlue's use of Conv1d with kernel_size of 1 with …
sbucaille Sep 6, 2024
f9861cd
feat: several changes to address comments
sbucaille Oct 11, 2024
d96b0a8
refactor: changed validate_and_format_image_pairs function with clarity
sbucaille Oct 12, 2024
f5dce0d
refactor: changed from one SuperGlueMLP class to a list of SuperGlueM…
sbucaille Oct 12, 2024
e270250
fix: fixed forgotten init weight change from last commit
sbucaille Oct 12, 2024
8172032
fix: fixed rebase mistake
sbucaille Oct 12, 2024
4f1ce85
fix: removed leftover commented code
sbucaille Oct 12, 2024
5f8c347
fix: added typehint and changed some of arguments default values
sbucaille Oct 14, 2024
8b9219e
fix: fixed attribute default values for SuperGlueConfig
sbucaille Oct 30, 2024
c3ca4a1
feat: added SuperGlueImageProcessor post process keypoint matching me…
sbucaille Oct 30, 2024
ed47ed0
fix: fixed SuperGlue attention and hidden state tuples aggregation
sbucaille Oct 30, 2024
e7f36c5
chore: fixed mask optionality and reordered tensor reshapes to be cle…
sbucaille Oct 30, 2024
b053497
chore: fixed docs and error message returned in validate_and_format_i…
sbucaille Oct 30, 2024
e9a0120
fix: fixed returned keypoints to be the ones that SuperPoint returns
sbucaille Oct 30, 2024
6269f49
fix: fixed check on number of image sizes for post process compared t…
sbucaille Oct 30, 2024
e788a02
fix: fixed check on number of image sizes for post process compared t…
sbucaille Oct 30, 2024
d92adca
fix: Changed SuperGlueMultiLayerPerceptron instantiation to avoid if …
sbucaille Nov 1, 2024
d76d28c
fix: Changed convert_superglue_to_hf script to reflect latest SuperGl…
sbucaille Nov 1, 2024
7691b83
WIP: implement Attention from an existing class (like BERT)
sbucaille Nov 3, 2024
0447476
docs: Changed docs to include more appealing matching plot
sbucaille Nov 3, 2024
2f924d7
WIP: Implement Attention
sbucaille Nov 3, 2024
60b9d3d
chore: minor typehint change
sbucaille Nov 3, 2024
13ae18d
chore: changed convert superglue script by removing all classes and a…
sbucaille Nov 6, 2024
c6b1177
Revert "Fixed typo in SuperPoint output doc"
sbucaille Nov 17, 2024
fe22517
chore: added comments in SuperGlueImageProcessor
sbucaille Nov 17, 2024
bc97e7f
chore: changed SuperGlue organization HF repo to magic-leap-community
sbucaille Nov 17, 2024
163dd04
[run-slow] refactor: small change in layer instantiation
sbucaille Nov 17, 2024
243b2fb
[run-slow] chore: replaced remaining stevenbucaille org to magic-leap…
sbucaille Nov 17, 2024
aac8b22
[run-slow] chore: make style
sbucaille Nov 17, 2024
f2fbe8a
chore: update image matching fixture dataset HF repository
sbucaille Nov 17, 2024
84bb579
[run-slow] superglue
sbucaille Nov 17, 2024
0faa7d2
tests: overwriting test_batching_equivalence
sbucaille Nov 17, 2024
b04cf00
[run-slow] superglue
sbucaille Nov 17, 2024
de6a1d5
tests: changed test to cope with value changing depending on cuda ver…
Nov 18, 2024
538404e
[run-slow] superglue
Nov 18, 2024
0d2825d
tests: changed matching_threshold value
Nov 18, 2024
4c28182
[run-slow] superglue
Nov 18, 2024
f01f206
[run-slow] superglue
Nov 19, 2024
8f165da
tests: changed tests for integration
Nov 20, 2024
c3773a5
[run-slow] superglue
Nov 20, 2024
c31e8e0
fix: Changed tensor view and permutations to match original implement…
Nov 25, 2024
63121d8
fix: updated convert script and integration test to include last chan…
Nov 25, 2024
7e5ac79
fix: increase tolerance for CUDA variances
Nov 25, 2024
c928128
Apply suggestions from code review
sbucaille Nov 25, 2024
2233c1f
[run-slow] superglue
Nov 25, 2024
c98e2e2
chore: removed blank whitespaces
Nov 25, 2024
d899649
[run-slow] superglue
Nov 25, 2024
60c1536
Revert SuperPoint image processor accident changes
Nov 25, 2024
061918f
[run-slow] superglue
Nov 25, 2024
ff94a08
refactor: reverted copy from BERT class
Nov 26, 2024
8ea374d
tests: lower the tolerance in integration tests for SuperGlue
Nov 26, 2024
e9c5483
[run-slow] superglue
Nov 26, 2024
5534cb4
chore: set do_grayscale to False in SuperPoint and SuperGlue image pr…
Nov 26, 2024
f8f5dd7
[run-slow] superglue
Nov 26, 2024
9ede8fa
fix: fixed imports in SuperGlue files
Nov 27, 2024
777ff09
chore: changed do_grayscale SuperGlueImageProcessing default value to…
Nov 27, 2024
732d964
docs: added typehint to post_process_keypoint_matching method in Supe…
Nov 27, 2024
55bfdb9
fix: set matching_threshold default value to 0.0 instead of 0.2
Nov 27, 2024
9c237c9
feat: added matching_threshold to post_process_keypoint_matching method
Nov 27, 2024
02fd468
docs: update superglue.md to include matching_threshold parameter
Nov 27, 2024
d34af9e
docs: updated SuperGlueConfig docstring for matching_threshold defaul…
Nov 27, 2024
ef6241b
refactor: removed unnecessary parameters in SuperGlueConfig
Nov 27, 2024
a802ead
fix: changed from matching_threshold to threshold
Nov 27, 2024
ea566d6
fix: re-revert changes to make SuperGlue attention classes copies of …
Nov 28, 2024
d4dbf2e
[run-slow] superglue
Nov 28, 2024
92e8894
fix: added missing device argument in post_processing method
sbucaille Dec 2, 2024
7e2687c
[run-slow] superglue
sbucaille Dec 2, 2024
8694cd5
fix: add matches different from -1 to compute valid matches in post_p…
sbucaille Dec 3, 2024
2ace6a6
fix: add device to image_sizes tensor instantiation
sbucaille Dec 3, 2024
8289e25
tests: added checks on do_grayscale test
sbucaille Dec 5, 2024
b395999
chore: reordered and added Optional typehint to KeypointMatchingOutput
sbucaille Dec 6, 2024
bc0a691
LightGluePR suggestions:
sbucaille Dec 20, 2024
4938770
LightGluePR suggestions:
sbucaille Dec 20, 2024
fd6a01b
refactor: processing images done in 1 for loop instead of 4
Jan 7, 2025
e906750
fix: use @ instead of torch.einsum for scores computation
Jan 7, 2025
97cf682
style: added #fmt skip to long tensor values
Jan 7, 2025
0ad7f2d
refactor: rollbacked validate_and_format_image_pairs valid and invali…
Jan 7, 2025
63ff94f
refactor: prepare_imgs
Jan 8, 2025
53d37dd
refactor: simplified `validate_and_format_image_pairs`
Jan 8, 2025
fb7cdc5
docs: fixed doc
Jan 8, 2025
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
2 changes: 2 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,8 @@
title: SegFormer
- local: model_doc/seggpt
title: SegGpt
- local: model_doc/superglue
title: SuperGlue
- local: model_doc/superpoint
title: SuperPoint
- local: model_doc/swiftformer
Expand Down
1 change: 1 addition & 0 deletions docs/source/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ Flax), PyTorch, and/or TensorFlow.
| [SqueezeBERT](model_doc/squeezebert) | ✅ | ❌ | ❌ |
| [StableLm](model_doc/stablelm) | ✅ | ❌ | ❌ |
| [Starcoder2](model_doc/starcoder2) | ✅ | ❌ | ❌ |
| [SuperGlue](model_doc/superglue) | ✅ | ❌ | ❌ |
| [SuperPoint](model_doc/superpoint) | ✅ | ❌ | ❌ |
| [SwiftFormer](model_doc/swiftformer) | ✅ | ✅ | ❌ |
| [Swin Transformer](model_doc/swin) | ✅ | ✅ | ❌ |
Expand Down
138 changes: 138 additions & 0 deletions docs/source/en/model_doc/superglue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<!--Copyright 2024 The HuggingFace Team. All rights reserved.

Licensed under the MIT License; you may not use this file except in compliance with
the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.


-->

# SuperGlue

## Overview

The SuperGlue model was proposed in [SuperGlue: Learning Feature Matching with Graph Neural Networks](https://arxiv.org/abs/1911.11763) by Paul-Edouard Sarlin, Daniel DeTone, Tomasz Malisiewicz and Andrew Rabinovich.

This model consists of matching two sets of interest points detected in an image. Paired with the
[SuperPoint model](https://huggingface.co/magic-leap-community/superpoint), it can be used to match two images and
estimate the pose between them. This model is useful for tasks such as image matching, homography estimation, etc.

The abstract from the paper is the following:

*This paper introduces SuperGlue, a neural network that matches two sets of local features by jointly finding correspondences
and rejecting non-matchable points. Assignments are estimated by solving a differentiable optimal transport problem, whose costs
are predicted by a graph neural network. We introduce a flexible context aggregation mechanism based on attention, enabling
SuperGlue to reason about the underlying 3D scene and feature assignments jointly. Compared to traditional, hand-designed heuristics,
our technique learns priors over geometric transformations and regularities of the 3D world through end-to-end training from image
pairs. SuperGlue outperforms other learned approaches and achieves state-of-the-art results on the task of pose estimation in
challenging real-world indoor and outdoor environments. The proposed method performs matching in real-time on a modern GPU and
can be readily integrated into modern SfM or SLAM systems. The code and trained weights are publicly available at this [URL](https://github.com/magicleap/SuperGluePretrainedNetwork).*

## How to use

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.
The raw outputs contain the list of keypoints detected by the keypoint detector as well as the list of matches with their corresponding
matching scores.
```python
from transformers import AutoImageProcessor, AutoModel
import torch
from PIL import Image
import requests

url_image1 = "https://raw.githubusercontent.com/magicleap/SuperGluePretrainedNetwork/refs/heads/master/assets/phototourism_sample_images/united_states_capitol_98169888_3347710852.jpg"
image1 = Image.open(requests.get(url_image1, stream=True).raw)
url_image2 = "https://raw.githubusercontent.com/magicleap/SuperGluePretrainedNetwork/refs/heads/master/assets/phototourism_sample_images/united_states_capitol_26757027_6717084061.jpg"
image_2 = Image.open(requests.get(url_image2, stream=True).raw)

images = [image1, image2]

processor = AutoImageProcessor.from_pretrained("magic-leap-community/superglue_outdoor")
model = AutoModel.from_pretrained("magic-leap-community/superglue_outdoor")

inputs = processor(images, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
```

You can use the `post_process_keypoint_matching` method from the `SuperGlueImageProcessor` to get the keypoints and matches in a more readable format:

```python
image_sizes = [[(image.height, image.width) for image in images]]
outputs = processor.post_process_keypoint_matching(outputs, image_sizes, threshold=0.2)
qubvel marked this conversation as resolved.
Show resolved Hide resolved
for i, output in enumerate(outputs):
print("For the image pair", i)
for keypoint0, keypoint1, matching_score in zip(
output["keypoints0"], output["keypoints1"], output["matching_scores"]
):
print(
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}."
)

```

From the outputs, you can visualize the matches between the two images using the following code:
```python
import matplotlib.pyplot as plt
import numpy as np

# Create side by side image
merged_image = np.zeros((max(image1.height, image2.height), image1.width + image2.width, 3))
merged_image[: image1.height, : image1.width] = np.array(image1) / 255.0
merged_image[: image2.height, image1.width :] = np.array(image2) / 255.0
plt.imshow(merged_image)
plt.axis("off")

# Retrieve the keypoints and matches
output = outputs[0]
keypoints0 = output["keypoints0"]
keypoints1 = output["keypoints1"]
matching_scores = output["matching_scores"]
keypoints0_x, keypoints0_y = keypoints0[:, 0].numpy(), keypoints0[:, 1].numpy()
keypoints1_x, keypoints1_y = keypoints1[:, 0].numpy(), keypoints1[:, 1].numpy()

# Plot the matches
for keypoint0_x, keypoint0_y, keypoint1_x, keypoint1_y, matching_score in zip(
keypoints0_x, keypoints0_y, keypoints1_x, keypoints1_y, matching_scores
):
plt.plot(
[keypoint0_x, keypoint1_x + image1.width],
[keypoint0_y, keypoint1_y],
color=plt.get_cmap("RdYlGn")(matching_score.item()),
alpha=0.9,
linewidth=0.5,
)
plt.scatter(keypoint0_x, keypoint0_y, c="black", s=2)
plt.scatter(keypoint1_x + image1.width, keypoint1_y, c="black", s=2)

# Save the plot
plt.savefig("matched_image.png", dpi=300, bbox_inches='tight')
plt.close()
Comment on lines +81 to +115
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you think it would make sense to add this to the image processor / processor ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like a plot_keypoint_matching(images, keypoint_matching_output, path) method ? or just as a docstring ?

Copy link
Collaborator

@ArthurZucker ArthurZucker Jan 8, 2025

Choose a reason for hiding this comment

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

Yeah a method sounds good

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 thought a bit about this but I think it depends on whether you want to put visualization forward in the library or not. Here in this example we assume only a pair of images, but as a method in the processor, should it handle multiple pairs like other methods ? If so, should we visualize the pairs individually / all together ? In terms of plotting, should we force the template we have here or allow some customization ?
On the other hand, I don't know your policy about that, but on this SuperPoint's PR, another contributor took the opportunity of us introducing the new keypoint detection task to implement visualization in roboflow/supervision (PR still under work in progress as it appears), maybe it could also be the case for keypoint matching ?

Copy link
Member

@qubvel qubvel Jan 8, 2025

Choose a reason for hiding this comment

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

do we have matplotlib dependency? otherwise, I would better just provide snippets in docs and model card (as we have right now)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be considered as resolved ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, we could have a soft dependency as well

```
qubvel marked this conversation as resolved.
Show resolved Hide resolved

![image/png](https://cdn-uploads.huggingface.co/production/uploads/632885ba1558dac67c440aa8/01ZYaLB1NL5XdA8u7yCo4.png)

This model was contributed by [stevenbucaille](https://huggingface.co/stevenbucaille).
The original code can be found [here](https://github.com/magicleap/SuperGluePretrainedNetwork).

## SuperGlueConfig

[[autodoc]] SuperGlueConfig

## SuperGlueImageProcessor

[[autodoc]] SuperGlueImageProcessor

- preprocess

## SuperGlueForKeypointMatching

[[autodoc]] SuperGlueForKeypointMatching

- forward
- post_process_keypoint_matching
14 changes: 14 additions & 0 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@
],
"models.stablelm": ["StableLmConfig"],
"models.starcoder2": ["Starcoder2Config"],
"models.superglue": ["SuperGlueConfig"],
"models.superpoint": ["SuperPointConfig"],
"models.swiftformer": ["SwiftFormerConfig"],
"models.swin": ["SwinConfig"],
Expand Down Expand Up @@ -1234,6 +1235,7 @@
_import_structure["models.segformer"].extend(["SegformerFeatureExtractor", "SegformerImageProcessor"])
_import_structure["models.seggpt"].extend(["SegGptImageProcessor"])
_import_structure["models.siglip"].append("SiglipImageProcessor")
_import_structure["models.superglue"].extend(["SuperGlueImageProcessor"])
_import_structure["models.superpoint"].extend(["SuperPointImageProcessor"])
_import_structure["models.swin2sr"].append("Swin2SRImageProcessor")
_import_structure["models.tvp"].append("TvpImageProcessor")
Expand Down Expand Up @@ -3402,6 +3404,12 @@
"Starcoder2PreTrainedModel",
]
)
_import_structure["models.superglue"].extend(
[
"SuperGlueForKeypointMatching",
"SuperGluePreTrainedModel",
]
)
_import_structure["models.superpoint"].extend(
[
"SuperPointForKeypointDetection",
Expand Down Expand Up @@ -5664,6 +5672,7 @@
)
from .models.stablelm import StableLmConfig
from .models.starcoder2 import Starcoder2Config
from .models.superglue import SuperGlueConfig
from .models.superpoint import SuperPointConfig
from .models.swiftformer import (
SwiftFormerConfig,
Expand Down Expand Up @@ -6159,6 +6168,7 @@
from .models.segformer import SegformerFeatureExtractor, SegformerImageProcessor
from .models.seggpt import SegGptImageProcessor
from .models.siglip import SiglipImageProcessor
from .models.superglue import SuperGlueImageProcessor
from .models.superpoint import SuperPointImageProcessor
from .models.swin2sr import Swin2SRImageProcessor
from .models.tvp import TvpImageProcessor
Expand Down Expand Up @@ -7901,6 +7911,10 @@
Starcoder2Model,
Starcoder2PreTrainedModel,
)
from .models.superglue import (
SuperGlueForKeypointMatching,
SuperGluePreTrainedModel,
)
from .models.superpoint import (
SuperPointForKeypointDetection,
SuperPointPreTrainedModel,
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
squeezebert,
stablelm,
starcoder2,
superglue,
superpoint,
swiftformer,
swin,
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/auto/configuration_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
("squeezebert", "SqueezeBertConfig"),
("stablelm", "StableLmConfig"),
("starcoder2", "Starcoder2Config"),
("superglue", "SuperGlueConfig"),
("superpoint", "SuperPointConfig"),
("swiftformer", "SwiftFormerConfig"),
("swin", "SwinConfig"),
Expand Down Expand Up @@ -575,6 +576,7 @@
("squeezebert", "SqueezeBERT"),
("stablelm", "StableLm"),
("starcoder2", "Starcoder2"),
("superglue", "SuperGlue"),
("superpoint", "SuperPoint"),
("swiftformer", "SwiftFormer"),
("swin", "Swin Transformer"),
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/auto/image_processing_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
("segformer", ("SegformerImageProcessor",)),
("seggpt", ("SegGptImageProcessor",)),
("siglip", ("SiglipImageProcessor",)),
("superglue", "SuperGlueImageProcessor"),
("swiftformer", ("ViTImageProcessor", "ViTImageProcessorFast")),
("swin", ("ViTImageProcessor", "ViTImageProcessorFast")),
("swin2sr", ("Swin2SRImageProcessor",)),
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/auto/modeling_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
("squeezebert", "SqueezeBertModel"),
("stablelm", "StableLmModel"),
("starcoder2", "Starcoder2Model"),
("superglue", "SuperGlueForKeypointMatching"),
("swiftformer", "SwiftFormerModel"),
("swin", "SwinModel"),
("swin2sr", "Swin2SRModel"),
Expand Down
28 changes: 28 additions & 0 deletions src/transformers/models/superglue/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import _LazyModule
from ...utils.import_utils import define_import_structure


if TYPE_CHECKING:
from .configuration_superglue import *
from .image_processing_superglue import *
from .modeling_superglue import *
else:
import sys

_file = globals()["__file__"]
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
Loading