Skip to content

Commit

Permalink
Merge branch 'master' into sarlinpe/retrieval-salad
Browse files Browse the repository at this point in the history
  • Loading branch information
sarlinpe authored Nov 3, 2024
2 parents 9ee1556 + abb2520 commit e04d5a5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
20 changes: 19 additions & 1 deletion hloc/extract_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@
"resize_max": 1600,
},
},
"aliked-n16": {
"output": "feats-aliked-n16",
"model": {
"name": "aliked",
"model_name": "aliked-n16",
},
"preprocessing": {
"grayscale": False,
"resize_max": 1024,
},
},
# Global descriptors
"dir": {
"output": "global-feats-dir",
Expand Down Expand Up @@ -312,4 +323,11 @@ def main(
parser.add_argument("--image_list", type=Path)
parser.add_argument("--feature_path", type=Path)
args = parser.parse_args()
main(confs[args.conf], args.image_dir, args.export_dir, args.as_half)
main(
confs[args.conf],
args.image_dir,
args.export_dir,
args.as_half,
args.image_list,
args.feature_path,
)
26 changes: 26 additions & 0 deletions hloc/extractors/aliked.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from lightglue import ALIKED as ALIKED_

from ..utils.base_model import BaseModel


class ALIKED(BaseModel):
default_conf = {
"model_name": "aliked-n16",
"max_num_keypoints": -1,
"detection_threshold": 0.2,
"nms_radius": 2,
}
required_inputs = ["image"]

def _init(self, conf):
conf.pop("name")
self.model = ALIKED_(**conf)

def _forward(self, data):
features = self.model(data)

return {
"keypoints": [f for f in features["keypoints"]],
"keypoint_scores": [f for f in features["keypoint_scores"]],
"descriptors": [f.t() for f in features["descriptors"]],
}
7 changes: 7 additions & 0 deletions hloc/match_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
"features": "disk",
},
},
"aliked+lightglue": {
"output": "matches-aliked-lightglue",
"model": {
"name": "lightglue",
"features": "aliked",
},
},
"superglue": {
"output": "matches-superglue",
"model": {
Expand Down
2 changes: 1 addition & 1 deletion hloc/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def read_image(path, grayscale=False):
mode = cv2.IMREAD_GRAYSCALE
else:
mode = cv2.IMREAD_COLOR
image = cv2.imread(str(path), mode)
image = cv2.imread(str(path), mode | cv2.IMREAD_IGNORE_ORIENTATION)
if image is None:
raise ValueError(f"Cannot read image {path}.")
if not grayscale and len(image.shape) == 3:
Expand Down

0 comments on commit e04d5a5

Please sign in to comment.