Realcat commited on
Commit
848664a
1 Parent(s): eb96f3c

add: xfeat+lightglue

Browse files
hloc/match_dense.py CHANGED
@@ -205,6 +205,21 @@ confs = {
205
  "dfactor": 16,
206
  },
207
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  "xfeat_dense": {
209
  "output": "matches-xfeat_dense",
210
  "model": {
 
205
  "dfactor": 16,
206
  },
207
  },
208
+ "xfeat_lightglue": {
209
+ "output": "matches-xfeat_lightglue",
210
+ "model": {
211
+ "name": "xfeat_lightglue",
212
+ "max_keypoints": 8000,
213
+ },
214
+ "preprocessing": {
215
+ "grayscale": False,
216
+ "force_resize": False,
217
+ "resize_max": 1024,
218
+ "width": 640,
219
+ "height": 480,
220
+ "dfactor": 8,
221
+ },
222
+ },
223
  "xfeat_dense": {
224
  "output": "matches-xfeat_dense",
225
  "model": {
hloc/matchers/xfeat_lightglue.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+
3
+ from hloc import logger
4
+
5
+ from ..utils.base_model import BaseModel
6
+
7
+
8
+ class XFeatLightGlue(BaseModel):
9
+ default_conf = {
10
+ "keypoint_threshold": 0.005,
11
+ "max_keypoints": 8000,
12
+ }
13
+ required_inputs = [
14
+ "image0",
15
+ "image1",
16
+ ]
17
+
18
+ def _init(self, conf):
19
+ self.net = torch.hub.load(
20
+ "verlab/accelerated_features",
21
+ "XFeat",
22
+ pretrained=True,
23
+ top_k=self.conf["max_keypoints"],
24
+ )
25
+ logger.info("Load XFeat(dense) model done.")
26
+
27
+ def _forward(self, data):
28
+ # we use results from one batch
29
+ im0 = data["image0"]
30
+ im1 = data["image1"]
31
+ # Compute coarse feats
32
+ out0 = self.net.detectAndCompute(im0, top_k=self.conf["max_keypoints"])[
33
+ 0
34
+ ]
35
+ out1 = self.net.detectAndCompute(im1, top_k=self.conf["max_keypoints"])[
36
+ 0
37
+ ]
38
+ out0.update({"image_size": (im0.shape[-1], im0.shape[-2])}) # W H
39
+ out1.update({"image_size": (im1.shape[-1], im1.shape[-2])}) # W H
40
+ mkpts_0, mkpts_1 = self.net.match_lighterglue(out0, out1)
41
+ mkpts_0 = torch.from_numpy(mkpts_0) # n x 2
42
+ mkpts_1 = torch.from_numpy(mkpts_1) # n x 2
43
+ pred = {
44
+ "keypoints0": mkpts_0,
45
+ "keypoints1": mkpts_1,
46
+ "mconf": torch.ones_like(mkpts_0[:, 0]),
47
+ }
48
+ return pred
requirements.txt CHANGED
@@ -6,7 +6,7 @@ gradio_client==0.16.0
6
  h5py==3.9.0
7
  imageio==2.31.1
8
  Jinja2==3.1.2
9
- kornia==0.6.12
10
  loguru==0.7.0
11
  matplotlib==3.7.1
12
  numpy==1.23.5
 
6
  h5py==3.9.0
7
  imageio==2.31.1
8
  Jinja2==3.1.2
9
+ kornia
10
  loguru==0.7.0
11
  matplotlib==3.7.1
12
  numpy==1.23.5
ui/config.yaml CHANGED
@@ -133,6 +133,17 @@ matcher_zoo:
133
  paper: https://arxiv.org/abs/2208.14201
134
  project: null
135
  display: true
 
 
 
 
 
 
 
 
 
 
 
136
  xfeat(sparse):
137
  matcher: NN-mutual
138
  feature: xfeat
 
133
  paper: https://arxiv.org/abs/2208.14201
134
  project: null
135
  display: true
136
+ xfeat+lightglue:
137
+ enable: true
138
+ matcher: xfeat_lightglue
139
+ dense: true
140
+ info:
141
+ name: xfeat+lightglue
142
+ source: "CVPR 2024"
143
+ github: https://github.com/Vincentqyw/omniglue-onnx
144
+ paper: https://arxiv.org/abs/2405.12979
145
+ project: https://hwjiang1510.github.io/OmniGlue
146
+ display: true
147
  xfeat(sparse):
148
  matcher: NN-mutual
149
  feature: xfeat