Robust Dense Feature Matching
Project description
RoMa 🏛️:
Robust Dense Feature Matching
⭐CVPR 2024⭐
Johan Edstedt · Qiyu Sun · Georg Bökman · Mårten Wadenbäck · Michael Felsberg
RoMa is the robust dense feature matcher capable of estimating pixel-dense warps and reliable certainties for almost any image pair.
Setup/Install
In your python environment (tested on Linux python 3.12), run:
uv pip install -e .
or
uv sync
You can also install romatch directly as a package from PyPI by
uv pip install romatch
or
uv add romatch
Fused local correlation kernel
Include the --extra fused-local-corr flag as:
uv sync --extra fused-local-corr
or
uv pip install romatch[fused-local-corr]
or
uv add romatch[fused-local-corr]
Demo / How to Use
We provide two demos in the demos folder. Here's the gist of it:
from romatch import roma_outdoor
roma_model = roma_outdoor(device=device)
# Match
warp, certainty = roma_model.match(imA_path, imB_path, device=device)
# Sample matches for estimation
matches, certainty = roma_model.sample(warp, certainty)
# Convert to pixel coordinates (RoMa produces matches in [-1,1]x[-1,1])
kptsA, kptsB = roma_model.to_pixel_coordinates(matches, H_A, W_A, H_B, W_B)
# Find a fundamental matrix (or anything else of interest)
F, mask = cv2.findFundamentalMat(
kptsA.cpu().numpy(), kptsB.cpu().numpy(), ransacReprojThreshold=0.2, method=cv2.USAC_MAGSAC, confidence=0.999999, maxIters=10000
)
New: You can also match arbitrary keypoints with RoMa. See match_keypoints in RegressionMatcher.
Settings
Resolution
By default RoMa uses an initial resolution of (560,560) which is then upsampled to (864,864). You can change this at construction (see roma_outdoor kwargs). You can also change this later, by changing the roma_model.w_resized, roma_model.h_resized, and roma_model.upsample_res.
Sampling
roma_model.sample_thresh controls the thresholding used when sampling matches for estimation. In certain cases a lower or higher threshold may improve results.
Reproducing Results
The experiments in the paper are provided in the experiments folder.
Training
- First follow the instructions provided here: https://github.com/Parskatt/DKM for downloading and preprocessing datasets.
- Run the relevant experiment, e.g.,
torchrun --nproc_per_node=4 --nnodes=1 --rdzv_backend=c10d experiments/roma_outdoor.py
Testing
python experiments/roma_outdoor.py --only_test --benchmark mega-1500
License
All our code except DINOv2 is MIT license. DINOv2 has an Apache 2 license DINOv2.
Acknowledgement
Our codebase builds on the code in DKM.
Tiny RoMa
If you find that RoMa is too heavy, you might want to try Tiny RoMa which is built on top of XFeat.
from romatch import tiny_roma_v1_outdoor
tiny_roma_model = tiny_roma_v1_outdoor(device=device)
Mega1500:
| AUC@5 | AUC@10 | AUC@20 | |
|---|---|---|---|
| XFeat | 46.4 | 58.9 | 69.2 |
| XFeat* | 51.9 | 67.2 | 78.9 |
| Tiny RoMa v1 | 56.4 | 69.5 | 79.5 |
| RoMa | - | - | - |
Mega-8-Scenes (See DKM):
| AUC@5 | AUC@10 | AUC@20 | |
|---|---|---|---|
| XFeat | - | - | - |
| XFeat* | 50.1 | 64.4 | 75.2 |
| Tiny RoMa v1 | 57.7 | 70.5 | 79.6 |
| RoMa | - | - | - |
IMC22 :'):
| mAA@10 | |
|---|---|
| XFeat | 42.1 |
| XFeat* | - |
| Tiny RoMa v1 | 42.2 |
| RoMa | - |
Reproducibility
There are a few diffs in the current codebase compared to the original repo used to run experiments.
- The
scale_factorused in thematchmethod now is relative to the original training resolution of560. Previosly it was based on the set coarse resolution (which might or might not be560). - Newer PyTorch, original code used something like
2.1. - Stochastic eval: both RANSAC and the chosen correspondences can affect results in
Mega1500. - Matrix inverse in GP has been replaced with cholesky decomp.
That being said, if diff of results are $>0.5$ there probably is something wrong, please let me know.
BibTeX
If you find our models useful, please consider citing our paper!
@inproceedings{edstedt2024roma,
title={{RoMa: Robust Dense Feature Matching}},
author={Edstedt, Johan and Sun, Qiyu and Bökman, Georg and Wadenbäck, Mårten and Felsberg, Michael},
booktitle={IEEE Conference on Computer Vision and Pattern Recognition},
year={2024}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file romatch_roicat-0.1.2.post1.tar.gz.
File metadata
- Download URL: romatch_roicat-0.1.2.post1.tar.gz
- Upload date:
- Size: 47.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8319a38419ad29ecce64a2ba8f2433bf4054db52dac92f7b5372a635c594d062
|
|
| MD5 |
621bace187e36220237c3de1f02c7c1b
|
|
| BLAKE2b-256 |
2d8a5c401a91cb053ca470c69448ba51742283b545bad7c6bb4b2808c351a4a4
|
File details
Details for the file romatch_roicat-0.1.2.post1-py3-none-any.whl.
File metadata
- Download URL: romatch_roicat-0.1.2.post1-py3-none-any.whl
- Upload date:
- Size: 67.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe0285bc0bad3c931e71ff79d078ef8d7211cd3f48a1cd281a68826518b718bd
|
|
| MD5 |
c7cab5db371bcc453bdaf2f20c5d903c
|
|
| BLAKE2b-256 |
c29e9ce0888947939711f512d6ed73c63e1df1affc76afcb2f721034e792545c
|