Skip to content

Add LoMa - #495

Open
davnords wants to merge 2 commits into
cvg:masterfrom
davnords:master
Open

Add LoMa#495
davnords wants to merge 2 commits into
cvg:masterfrom
davnords:master

Conversation

@davnords

Copy link
Copy Markdown

Attempt to add the LoMa matcher from LoMa: Local Feature Matching Revisited.

Verification

When I benchmarked LoMa-B on InLoc, using the following simple script:

from pathlib import Path
from hloc import extract_features, match_features, localize_inloc

if __name__ == "__main__":
    print(f"Running matcher")
    dataset = Path("data/inloc")  # change this if your dataset is somewhere else

    pairs = Path("pairs/inloc")
    loc_pairs = pairs / "pairs-query-netvlad40.txt"  # top 40 retrieved by NetVLAD

    outputs = Path("outputs/inloc")  # where everything will be saved
    results = outputs / f"InLoc_loma_netvlad40.txt"  # the result file
    feature_conf = extract_features.confs["loma_inloc"]
    matcher_conf = match_features.confs["loma"]

    feature_path = extract_features.main(feature_conf, dataset, outputs)
    match_path = match_features.main(matcher_conf, loc_pairs, feature_conf["output"], outputs, overwrite=False)# True)
    localize_inloc.main(
        dataset, loc_pairs, feature_path, match_path, results, skip_matches=20
    )

I achieved the following results:

DUC1: 55.1 / 80.3 / 91.4 
DUC2: 72.5 / 87.8 / 88.5

This is similar to the results reported in the paper and an almost 20-point improvement on DUC2 (0.25m, 10°) compared to what is reported in the LightGlue paper.

Thank you very much for your work.

/ David

@davnords

Copy link
Copy Markdown
Author

@sarlinpe Perhaps this matcher be interest you :)

LoMa.

/ David

@omaralvarez

Copy link
Copy Markdown

This matcher would be a great addition, hoping it gets merged!

@Parskatt

Copy link
Copy Markdown
Contributor

@sarlinpe anything else required for merge?

@omaralvarez

Copy link
Copy Markdown

I have been testing the implementation and I found an issue with the Dockerfile of hloc. For up to date colmap, hloc, and LoMa, the Python version needs to be bumped to 3.10, if not the docker build errors out. Additionally, probably due to being based in the colmap image it is missing git.

In python 3.10, dataclasses is already included in the Python standard library, leading to a dependency conflict when installing lomatch @ git+https://github.com/davnords/LoMa.

Just removing the dataclasses in the .toml in LoMa would fix this issue. I could create another pull request with the updated Dockerfile.

@Parskatt

Copy link
Copy Markdown
Contributor

Now fixed.

@omaralvarez

omaralvarez commented Apr 30, 2026

Copy link
Copy Markdown

I confirm now docker works well with the change and my Dockerfile pull request #497 . I have also tested LoMa with a difficult reconstruction and it works really well.

@omaralvarez

omaralvarez commented Apr 30, 2026

Copy link
Copy Markdown

Shouldn't we make available through config all LoMa weights (loma_R, loma_L, etc.)? It would be great to be able to use the LoMa-R version. I think right now LoMa-R is missing, please correct me if I am wrong.

@davnords

davnords commented May 1, 2026

Copy link
Copy Markdown
Author

Thank you @omaralvarez for testing. I am glad LoMa performed well on difficult reconstructions. I have now added LoMa-R to the configs.

@ichsan2895

Copy link
Copy Markdown

Why it is not merged yet 😢

ahojnnes added a commit to colmap/colmap that referenced this pull request Aug 18, 2026
In accordance with a brief discussion with @ahojnnes at CVPR, here is a
PR for adding the LoMa matcher.

For reference on the LoMa matcher, we refer to the paper, [LoMa: Local
Feature Matching Revisited](https://arxiv.org/abs/2604.04931), and the
code,
[https://github.com/davnords/loma](https://github.com/davnords/loma).

The PR is basically a copy-paste of how the integration with ALIKED+LG
already was made.

**Note:** The ONNX files are currently hosted on my own GitHub storage
project. Feel free to download them and add them as a release to colmap
to align the download links with where the other weights are hosted.

This PR is restricted to LoMa-B. I think this will benefit the community
the most as the matcher is quick (same speed as LG) and lightweight
while the detector / descriptor are a little slower but the full
pipeline is very powerful (see below).

Happy to fix anything that would improve the integration.

## Tests

I used it for reconstruction on South Building (128 images) and it
looked good. I also made sure the feature matches looked decent on a
MegaDepth pair.
<img width="1093" height="399" alt="Skärmavbild 2026-07-09 kl 14 57 30"
src="https://github.com/user-attachments/assets/bae76061-e9e9-4219-b614-cb0385d7e9ba"
/>

To provide some background on the strength of LoMa: In an HLoc
[fork](cvg/Hierarchical-Localization#495) we run
Visual Localization on InLoc and get:
```
DUC1: 55.1 / 80.3 / 91.4 
DUC2: 72.5 / 87.8 / 88.5
```
This is similar to the results reported in the
[paper](https://arxiv.org/abs/2604.04931) and an almost 20-point
improvement on DUC2 (0.25m, 10°) compared to what is reported in the
[LightGlue](https://arxiv.org/abs/2306.13643) paper.

## Acknowledgements

Credit to [aliejabbari](https://github.com/aliejabbari) for providing
the code for the ONNX export.

/ David

---------

Co-authored-by: David Nordström <davnords@arrhenius1.hpc.arrhenius.naiss.se>
Co-authored-by: Ali Jabbari <alijabbari.contact@gmail.com>
Co-authored-by: Johannes Schönberger <jsch@meta.com>
Co-authored-by: Johannes Schönberger <jsch@demuc.de>
Co-authored-by: Shaohui Liu <b1ueber2y@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants