forked from cvg/Hierarchical-Localization
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlightglue.py
33 lines (27 loc) · 888 Bytes
/
lightglue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from lightglue import LightGlue as LightGlue_
from ..utils.base_model import BaseModel
class LightGlue(BaseModel):
default_conf = {
"features": "superpoint",
"depth_confidence": 0.95,
"width_confidence": 0.99,
}
required_inputs = [
"image0",
"keypoints0",
"descriptors0",
"image1",
"keypoints1",
"descriptors1",
]
def _init(self, conf):
self.net = LightGlue_(conf.pop("features"), **conf)
def _forward(self, data):
data["descriptors0"] = data["descriptors0"].transpose(-1, -2)
data["descriptors1"] = data["descriptors1"].transpose(-1, -2)
return self.net(
{
"image0": {k[:-1]: v for k, v in data.items() if k[-1] == "0"},
"image1": {k[:-1]: v for k, v in data.items() if k[-1] == "1"},
}
)