Skip to content

Added MegaLoc and removed EigenPlaces #458

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

Merged
merged 1 commit into from
Mar 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ We show in [`pipeline_SfM.ipynb`](https://nbviewer.jupyter.org/github/cvg/Hierar

- Supported local feature extractors: [SuperPoint](https://arxiv.org/abs/1712.07629), [DISK](https://arxiv.org/abs/2006.13566), [D2-Net](https://arxiv.org/abs/1905.03561), [SIFT](https://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf), and [R2D2](https://arxiv.org/abs/1906.06195).
- Supported feature matchers: [SuperGlue](https://arxiv.org/abs/1911.11763), its faster follow-up [LightGlue](https://github.com/cvg/LightGlue), and nearest neighbor search with ratio test, distance test, and/or mutual check. hloc also supports dense matching with [LoFTR](https://github.com/zju3dv/LoFTR).
- Supported image retrieval: [NetVLAD](https://arxiv.org/abs/1511.07247), [AP-GeM/DIR](https://github.com/naver/deep-image-retrieval), [OpenIBL](https://github.com/yxgeee/OpenIBL), [CosPlace](https://github.com/gmberton/CosPlace) and [EigenPlaces](https://github.com/gmberton/EigenPlaces).
- Supported image retrieval: [NetVLAD](https://arxiv.org/abs/1511.07247), [AP-GeM/DIR](https://github.com/naver/deep-image-retrieval), [OpenIBL](https://github.com/yxgeee/OpenIBL), and [MegaLoc](https://github.com/gmberton/MegaLoc).

Using NetVLAD for retrieval, we obtain the following best results:

Expand Down
6 changes: 3 additions & 3 deletions hloc/extract_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@
"model": {"name": "openibl"},
"preprocessing": {"resize_max": 1024},
},
"eigenplaces": {
"output": "global-feats-eigenplaces",
"model": {"name": "eigenplaces"},
"megaloc": {
"output": "global-feats-megaloc",
"model": {"name": "megaloc"},
"preprocessing": {"resize_max": 1024},
},
}
Expand Down
57 changes: 0 additions & 57 deletions hloc/extractors/eigenplaces.py

This file was deleted.

27 changes: 27 additions & 0 deletions hloc/extractors/megaloc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
Code to use MegaLoc as a global features extractor.

MegaLoc paper: https://arxiv.org/abs/2502.17237
"""

import torch
import torchvision.transforms as tvf

from ..utils.base_model import BaseModel


class MegaPlaces(BaseModel):
required_inputs = ["image"]

def _init(self, conf):
self.net = torch.hub.load("gmberton/MegaLoc", "get_trained_model").eval()
mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]
self.norm_rgb = tvf.Normalize(mean=mean, std=std)

def _forward(self, data):
image = self.norm_rgb(data["image"])
desc = self.net(image)
return {
"global_descriptor": desc,
}