Skip to content
项目

关于

[CVPR'24 & TPAMI'26 & PR'26] Area to Point Matching Framework

人工智能与机器学习

这些数字如何统计

实测星标增长

24小时
0
7天
正在收集历史
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文
MESA logo

A2PM: Area to Point Matching

Match areas first, then points.
A training-free, plug-and-play framework that boosts any point matcher on high-resolution images and large viewpoint or scale changes.

Project Page MESA CVPR 2024 DMESA TPAMI SGAM PR arXiv Video License

A2PM

Resizing the whole image (top) distorts it and loses local detail. A2PM (bottom) first matches areas, runs the point matcher (PM) on each cropped pair, and fuses the results.

This repository is the official, Hydra-based implementation of the A2PM family:

Method Venue Area matching Links
SGAM Pattern Recognition 2026 Semantic prior + geometric consistency paper · arXiv · early code
MESA CVPR 2024 SAM area graph + graph-cut energy minimization (this repo ships a training-free variant, MESA-free) paper · project
DMESA TPAMI 2026 Dense area-matching distributions (GMM + EM), ~5× faster than MESA paper · arXiv · project

Highlights

  • 🔌 Plug-and-play: matcher-agnostic — any point matcher that outputs 2D correspondences can be wrapped as a thin adapter, with no retraining. 7 integrations ship in this repo (SP+SG, LoFTR, ASpanFormer, ELoFTR, DKM, DUSt3R, MASt3R), covering sparse, semi-dense and dense matching.
  • 📈 Consistent gains: e.g. +11.2 Pose AUC@5 on MegaDepth-1500 for MASt3R (46.34 → 57.58) with DMESA. See Results.
  • 🧩 Modular: every component is a class + yaml pair, so you can combine area matchers, point matchers and fusion modules with one line of config.

📰 News

🖼️ Qualitative Results

Qua

Continuous matching of SGAM (top to bottom: SGAM, SGAM + ASpan, ASpan)

gif

Contents


🛠 Installation

# 1. Clone with submodules (point matchers, SAM and MASt3R are git submodules)
git clone --recursive https://github.com/Easonyesheng/A2PM-MESA
cd A2PM-MESA
# already cloned without --recursive?  ->  git submodule update --init --recursive

# 2. Create the environment
conda create -n A2PM python=3.8 -y
conda activate A2PM

# 3. Install PyTorch (tested with 2.0.0 + CUDA 11.8; other versions should also work)
pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1 \
    --index-url https://download.pytorch.org/whl/cu118

# 4. Install the remaining dependencies
pip install -r requirements.txt

[!TIP] On Windows 11, see the step-by-step manual (中文).

MASt3R and DUSt3R need their own environment. See MASt3R & DUSt3R notes.

Pre-trained weights are not included. Download the weights for the point matcher you use and set the path in its conf/point_matcher/*.yaml.

🚀 Quick Start

A sample pair from ETH3D, with SAM results and intrinsics, is included in demo/.

cd scripts
python demo.py +experiment=demo out_path=/path/to/save/results
  • Entry point: scripts/demo.py. Config: conf/experiment/demo.yaml (DMESA + EGAM + SP/SG by default).
  • Other ready-made pipelines: conf/experiment/demo_*.yaml, for example python demo.py +experiment=demo_eloftr.
  • Use geo_area_matcher: gam to draw the matching results. egam needs camera intrinsics (demo/intrins/). Without intrinsics, use gam.
  • Your own images need SAM results in samres/. See Segmentation Preprocessing.
Which part of this README do I need?
I want to… Go to
check that my environment works Quick Start
reproduce numbers on ScanNet / MegaDepth Segmentation Preprocessing → Benchmark
plug in my own point / area matcher Configuration Guide

Segmentation Preprocessing

The area matchers rely on SAM masks, so these must be computed first.

  1. A forked SAM is provided as a submodule in SAM/. Install it:
    cd SAM && pip install -e . && cd ..
    pip install opencv-python pycocotools matplotlib onnxruntime onnx
    
  2. Download sam_vit_h_4b8939.pth into SAM/. Otherwise, edit sam_model_path in segmentor/ImgSAMSeg.py.
  3. Run segmentation following the examples in segmentor/sam_seg.sh.
Using SAM2
  • Set --sam_name SAM2 in segmentor/sam_seg.sh and set the checkpoint path in segmentor/ImgSAMSeg.py.
  • SAM2 is faster but tends to produce fewer masks than SAM (issue).
  • If you hit a Hydra initialization error, add this to SAM2/sam2/__init__.py:
    from hydra.core.global_hydra import GlobalHydra
    GlobalHydra.instance().clear()
    

⚙️ Configuration Guide

The code uses Hydra. Each component is a Python class instantiated from a yaml file with the same name, and an experiment file in conf/experiment/ composes them:

conf/
├── dataset/           # ScanNet1500, MegaDepth1500, demo pair      →  dataloader/
├── area_matcher/      # sem_area_matcher (SGAM), mesa-f, dmesa     →  area_matchers/
├── point_matcher/     # spsg, loftr, aspan, eloftr, dkm, dust3r, mast3r  →  point_matchers/
├── geo_area_matcher/  # gam, egam                                  →  geo_area_matchers/
├── evaler/            # instance_eval                              →  metric/
└── experiment/        # full pipelines: a2pm_{AM}_{GAM}_{PM}_{dataset}.yaml, demo*.yaml

To add a new component, add a class in the code folder and a yaml with the same name in the config folder.

Dataset
  • Dataloaders are provided for ScanNet1500 and MegaDepth1500. Download them following LoFTR and set the paths in conf/dataset/.
  • Set the segmentation fields as well:
    • sem_mode: SAM, SEEM or GT
    • sem_folder: folder containing the segmentation results
    • sem_post: file extension (ScanNet: npy for SAM, png for SEEM/GT)
  • Add a new dataset with a loader in dataloader/ and a config in conf/dataset/.
Area matching: the core of A2PM

Area matching finds semantic area correspondences, reducing matching redundancy before point matching.

Area matcher Code Config Notes
SGAM area_matchers/sem_am.py conf/area_matcher/sem_area_matcher.yaml paper, early code
MESA-free area_matchers/mesa.py conf/area_matcher/mesa-f.yaml Training-free MESA. Replaces the learned area similarity with off-the-shelf patch matching (as in DMESA). Easier to use, slightly lower accuracy than the original MESA
DMESA area_matchers/dmesa.py conf/area_matcher/dmesa.yaml Dense counterpart of MESA, more efficient and flexible
Point matching
Type Matchers
Sparse SuperPoint + SuperGlue
Semi-dense ASpanFormer, LoFTR, ELoFTR
Dense DKM, MASt3R, DUSt3R
  • Adapters live in point_matchers/ (each subclasses AbstractPointMatcher and implements a single match() method) with their configs in conf/point_matcher/. The table lists the 7 integrations that ship here, not a closed set — any matcher that outputs 2D correspondences can be added without touching the rest of the pipeline.
  • The submodules are forks with their internal import paths already fixed, so clone with --recursive.
  • Download the pre-trained weights and set their paths in the corresponding yaml.
MASt3R & DUSt3R notes
  1. Fetch the nested submodules: run git submodule update --init --recursive inside reconer/mast3r/ to get dust3r and dust3r/croco.
  2. Create the environment following the MASt3R repo, then:
    pip install loguru hydra-core seaborn kornia yacs pytorch-lightning PyMaxFlow
    
  3. Weights: conf/point_matcher/mast3r.yaml and dust3r.yaml use the Hugging Face model ids naver/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric and naver/DUSt3R_ViTLarge_BaseDecoder_512_dpt by default. These are downloaded automatically the first time you run them. To use local checkpoints (download), set weight_path to the .pth file. For MASt3R as the area matcher, also set mast3r_weight_path (an HF id or a local path) in:
  4. Run: cd scripts && python demo.py +experiment=demo_dmesa_mast3r
Match fusion (Geometry Area Matching)

Matches from all area pairs are fused by geometry area matching:

Module Code Config
GAM (from SGAM) geo_area_matchers/gam.py conf/geo_area_matcher/gam.yaml
EGAM (more effective, needs intrinsics) geo_area_matchers/egam.py conf/geo_area_matcher/egam.yaml
Evaluation
  • Metrics in metric/: pose estimation AUC, mean matching accuracy (MMA) and area matching accuracy.
  • metric/instance_eval.py evaluates each pair and is called from scripts/test_a2pm.py.
  • metric/eval_ratios.py aggregates the results of a whole benchmark run.

📊 Benchmark

Scripts follow the naming scheme scripts/{area-matcher}-{point-matcher}-{dataset}.sh:

cd scripts
./dmesa-dkm-md.sh            # DMESA + DKM on MegaDepth1500

# aggregate metrics; --root_folder is ${project_name}-res from the shell script
python ../metric/eval_ratios.py --root_folder dmesa-dkm-md-eval-res

[!IMPORTANT] Before running a benchmark script, set exp_root_path in the .sh file to your clone of this repo, and set out_path in the corresponding conf/experiment/*.yaml. eval_ratios.py reads results from <repo>/res by default. If your out_path points elsewhere, pass --root_path /your/output/root.

The full pipeline is scripts/test_a2pm.py. Switch methods by changing +experiment=... in the shell script.

Results

Relative pose AUC (%) produced by the scripts in this repo. Bold marks the best result in each row.

Point matcherDataset (input size)MetricBaseline+ MESA-free+ DMESA
DKMScanNet1500 (640×480)AUC@530.2631.6430.96
AUC@1051.5152.8052.41
AUC@2069.4370.0869.74
MegaDepth1500 (832×832)AUC@563.6163.8565.65
AUC@1076.7577.3878.46
AUC@2085.7286.4786.97
MASt3RScanNet1500 (512×512)AUC@528.2532.7934.23
AUC@1051.0155.1356.23
AUC@2069.6972.6073.42
MegaDepth1500 (512×512)AUC@546.3453.9857.58
AUC@1063.0269.9972.00
AUC@2076.5081.8082.86
DUSt3RScanNet1500 (512×512)AUC@515.8420.7223.01
AUC@1032.6939.1442.89
AUC@2049.3656.6260.86
MegaDepth1500 (512×512)AUC@515.9925.9424.48
AUC@1033.6944.0442.37
AUC@2053.5161.8361.04
ELoFTRScanNet1500 (640×480)AUC@522.1523.6223.07
AUC@1041.0842.3741.66
AUC@2057.9158.6658.27

Configs: conf/experiment/a2pm_{mesa|dmesa}_egam_{dkm|mast3r|dust3r|eloftr}_{megadepth|scannet}.yaml. MASt3R and DUSt3R use 512×512 inputs and ELoFTR uses 640×480, matching their training resolutions. ELoFTR was evaluated on ScanNet1500 only, with official weights.

Notes on reproducibility
  • These numbers were obtained before a GAM bug fix in 200e33a. Results from later commits may differ slightly, and alpha_list may need retuning.
  • The random seed is fixed to 2 (see scripts/test_a2pm.py), whereas the paper did not fix it. DMESA numbers therefore differ slightly from the paper, but the trends are the same.
  • MESA-free is a little less accurate than the paper version of MESA, but it still improves on the baselines.
  • Default parameters are not tuned for each area matcher + point matcher combination. Tuning for a specific dataset or task can improve results further.

📖 Citation

If you find this work useful, please consider citing:

@article{zhang2026dmesa,
  title   = {MESA: Effective Matching Redundancy Reduction by Semantic Area Segmentation},
  author  = {Zhang, Yesheng and Shen, Shuhan and Zhao, Xu},
  journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
  volume  = {48},
  number  = {4},
  pages   = {4454--4472},
  year    = {2026},
  doi     = {10.1109/TPAMI.2025.3644296}
}

@inproceedings{zhang2024mesa,
  title     = {MESA: Matching Everything by Segmenting Anything},
  author    = {Zhang, Yesheng and Zhao, Xu},
  booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  pages     = {20217--20226},
  year      = {2024}
}

@article{zhang2026sgam,
  title   = {Searching from Area to Point: A Semantic Guided Framework with Geometric Consistency for Accurate Feature Matching},
  author  = {Zhang, Yesheng and Zhao, Xu},
  journal = {Pattern Recognition},
  volume  = {179},
  pages   = {113920},
  year    = {2026},
  doi     = {10.1016/j.patcog.2026.113920}
}

🙏 Acknowledgement

This project builds on these excellent works: SAM, SuperPoint + SuperGlue, ASpanFormer, LoFTR, ELoFTR, DKM, DUSt3R, MASt3R and SGAM.

探索相关项目

加载中…