Spaces:
Sleeping
Sleeping
Vincentqyw
commited on
Commit
•
6cb641c
1
Parent(s):
52878a0
update: return matching score
Browse files- hloc/match_dense.py +2 -0
- hloc/matchers/aspanformer.py +5 -4
- hloc/matchers/loftr.py +2 -2
- hloc/matchers/roma.py +6 -3
- hloc/matchers/topicfm.py +5 -8
hloc/match_dense.py
CHANGED
@@ -353,6 +353,8 @@ def match_images(model, image_0, image_1, conf, device="cpu"):
|
|
353 |
}
|
354 |
if "mconf" in pred.keys():
|
355 |
ret["mconf"] = pred["mconf"].cpu().numpy()
|
|
|
|
|
356 |
else:
|
357 |
ret["mconf"] = np.ones_like(kpts0.cpu().numpy()[:, 0])
|
358 |
if "lines0" in pred.keys() and "lines1" in pred.keys():
|
|
|
353 |
}
|
354 |
if "mconf" in pred.keys():
|
355 |
ret["mconf"] = pred["mconf"].cpu().numpy()
|
356 |
+
elif "scores" in pred.keys(): #adapting loftr
|
357 |
+
ret["mconf"] = pred["scores"].cpu().numpy()
|
358 |
else:
|
359 |
ret["mconf"] = np.ones_like(kpts0.cpu().numpy()[:, 0])
|
360 |
if "lines0" in pred.keys() and "lines1" in pred.keys():
|
hloc/matchers/aspanformer.py
CHANGED
@@ -93,8 +93,9 @@ class ASpanFormer(BaseModel):
|
|
93 |
"image1": data["image1"],
|
94 |
}
|
95 |
self.net(data_, online_resize=True)
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
100 |
return pred
|
|
|
93 |
"image1": data["image1"],
|
94 |
}
|
95 |
self.net(data_, online_resize=True)
|
96 |
+
pred = {
|
97 |
+
"keypoints0": data_["mkpts0_f"],
|
98 |
+
"keypoints1": data_["mkpts1_f"],
|
99 |
+
"mconf": data_["mconf"],
|
100 |
+
}
|
101 |
return pred
|
hloc/matchers/loftr.py
CHANGED
@@ -2,7 +2,7 @@ import torch
|
|
2 |
import warnings
|
3 |
from kornia.feature.loftr.loftr import default_cfg
|
4 |
from kornia.feature import LoFTR as LoFTR_
|
5 |
-
|
6 |
from ..utils.base_model import BaseModel
|
7 |
|
8 |
|
@@ -18,7 +18,7 @@ class LoFTR(BaseModel):
|
|
18 |
cfg = default_cfg
|
19 |
cfg["match_coarse"]["thr"] = conf["match_threshold"]
|
20 |
self.net = LoFTR_(pretrained=conf["weights"], config=cfg)
|
21 |
-
|
22 |
def _forward(self, data):
|
23 |
# For consistency with hloc pairs, we refine kpts in image0!
|
24 |
rename = {
|
|
|
2 |
import warnings
|
3 |
from kornia.feature.loftr.loftr import default_cfg
|
4 |
from kornia.feature import LoFTR as LoFTR_
|
5 |
+
from hloc import logger
|
6 |
from ..utils.base_model import BaseModel
|
7 |
|
8 |
|
|
|
18 |
cfg = default_cfg
|
19 |
cfg["match_coarse"]["thr"] = conf["match_threshold"]
|
20 |
self.net = LoFTR_(pretrained=conf["weights"], config=cfg)
|
21 |
+
logger.info(f"Loaded LoFTR with weights {conf['weights']}")
|
22 |
def _forward(self, data):
|
23 |
# For consistency with hloc pairs, we refine kpts in image0!
|
24 |
rename = {
|
hloc/matchers/roma.py
CHANGED
@@ -85,7 +85,10 @@ class Roma(BaseModel):
|
|
85 |
kpts1, kpts2 = self.net.to_pixel_coordinates(
|
86 |
matches, H_A, W_A, H_B, W_B
|
87 |
)
|
88 |
-
pred = {
|
89 |
-
|
90 |
-
|
|
|
|
|
|
|
91 |
return pred
|
|
|
85 |
kpts1, kpts2 = self.net.to_pixel_coordinates(
|
86 |
matches, H_A, W_A, H_B, W_B
|
87 |
)
|
88 |
+
pred = {
|
89 |
+
"keypoints0": kpts1,
|
90 |
+
"keypoints1": kpts2,
|
91 |
+
"mconf": certainty,
|
92 |
+
}
|
93 |
+
|
94 |
return pred
|
hloc/matchers/topicfm.py
CHANGED
@@ -34,12 +34,9 @@ class TopicFM(BaseModel):
|
|
34 |
"image1": data["image1"],
|
35 |
}
|
36 |
self.net(data_)
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
pred = {}
|
43 |
-
pred["keypoints0"], pred["keypoints1"] = mkpts0, mkpts1
|
44 |
-
pred["mconf"] = mconf
|
45 |
return pred
|
|
|
34 |
"image1": data["image1"],
|
35 |
}
|
36 |
self.net(data_)
|
37 |
+
pred = {
|
38 |
+
"keypoints0": data_["mkpts0_f"],
|
39 |
+
"keypoints1": data_["mkpts1_f"],
|
40 |
+
"mconf": data_["mconf"],
|
41 |
+
}
|
|
|
|
|
|
|
42 |
return pred
|