RoMa
RoMa (2024): dense matching between two photos of one scene from any viewpoints: where each pixel of the first image is in the second, and how sure the model is that it is visible there. Built on Meta's DINOv2 and a VGG19. MIT code and weights; the DINOv2 weights are Apache-2.0.
experimental Fork of Parskatt/RoMa@77f8d68 · backends: portable, kernels
- Paper RoMa: Robust Dense Feature Matching CVPR 2024 · first released 24 May 2023
Checkpoint romav1
Paper 2023 Added in 0.2.0 Evaluated with 0.2.0
Use it
pip install fastforks Lean install with only what this model needs: pip install fastforks-core
from fastforks import matching
model = matching.load("romav1") # kernels on a supported GPU, else portable PyTorch
result = model(image_a, image_b)
result.warp # also: certainty
result.backend # what ran: mode, device, dtype, kernels
points1, points2 = result.matches(5000) # matched pixels, sampled where the model is certain
pose = matching.estimate_pose(points1, points2, K1, K2) # relative pose on the GPU (RANSAC); K = intrinsics [3, 3]
pose.R, pose.t, pose.inliers # rotation, unit translation, inlier mask fastforks bench romav1 Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.
Speed and memory
Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.
Input: synthetic, 768x1024 (the task’s standard size)
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | not measured | – | – | – | – |
| Original fp16the authors' mixed-precision option (float16); upstream RoMa v1 match, one direction; local correlation: upstream's plain-torch path (use_custom_corr off) | fp16 | 386 | – | 3,887 MiB/4,094 MiB | 4.9 | 0.47 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 377 | 1.0× | 1,720 MiB/1,840 MiB | 2.3 | 0.92 |
| Kernels | fp16 | 356 | 1.1× | 1,720 MiB/1,860 MiB | 3.2 | 1.03 |
| Portable + torch.compile | 247 | 1.6× | 1,348 MiB/1,476 MiB | 698 (build) | – | |
| TensorRTplanned for 0.2.1 | fails | – | – | – | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-13 to 2026-11-16. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two
times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.
Other devices
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-13 | Original | fp32 | 12208 | 12.2 GiB process | – | 768x1024 |
| Portable | fp32 | 3050 | 7,979 MiB process | matches | 768x1024 | |
| Kernels | fp16 | not implemented | – | 768x1024 | ||
CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.
Licence and weights
Accuracy
The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.
MegaDepth-1500
relative pose AUC@5 / @10 / @20 degrees
| Run | dtype | AUC@5° ↑ | AUC@10° ↑ | AUC@20° ↑ | pairs | ms / pair |
|---|---|---|---|---|---|---|
| Original fp32 | not measured | |||||
| Original fp16 | fp16 | 62.6 | 76.6 | 86.3 | 1500 | 1477 |
| Portable fp32 | not measured | |||||
| Portable | fp16 | 62.6 | 76.6 | 86.4 | 1500 | 1408 |
| Kernels | fp16 | 62.4 | 76.4 | 86.2 | 1500 | 1343 |
The original code was not run on this dataset, so the table cannot show the distance to it.
Dense matchers: 5000 matches per pair sampled from the warp by certainty (upstream's balanced KDE sampling); sparse matchers: all their matches of one call (LightGlue, XFeat: LightGlue's MegaDepth-1500 setting; LoFTR, DeDoDe: their card defaults). OpenCV essential-matrix RANSAC (0.5 px threshold, normalised by the mean focal length); AUC of the larger of the rotation and translation-direction errors. Original = the authors’ code, same checkpoint and protocol. Measured on original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks f218aa9d, 2026-11-13.
MegaDepth-1500
every 10th pair, relative pose AUC@5 / @10 / @20 degrees
| Run | dtype | AUC@5° ↑ | AUC@10° ↑ | AUC@20° ↑ | Δ AUC@5° vs fp32 original | pairs | ms / pair |
|---|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 67.6 | 80.1 | 88.2 | reference | 150 | 2115 |
| Original fp16 | fp16 | 66.4 | 79.5 | 88.1 | −1.2 | 150 | 1477 |
| Portable fp32 | fp32 | 66.5 | 79.7 | 88.0 | −1.1 | 150 | 2812 |
| Portable | fp16 | 68.2 | 80.8 | 88.8 | +0.6 | 150 | 1408 |
| Kernels | fp16 | 67.5 | 80.0 | 88.2 | −0.1 | 150 | 1343 |
Dense matchers: 5000 matches per pair sampled from the warp by certainty (upstream's balanced KDE sampling); sparse matchers: all their matches of one call (LightGlue, XFeat: LightGlue's MegaDepth-1500 setting; LoFTR, DeDoDe: their card defaults). OpenCV essential-matrix RANSAC (0.5 px threshold, normalised by the mean focal length); AUC of the larger of the rotation and translation-direction errors. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13; portable fp32, portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks f218aa9d, 2026-11-13.
Relative pose on the GPU
A dense matcher is usually followed by RANSAC on its matches to get the camera motion. fastforks does that step on the
GPU too: result.matches(n) samples matched points where the model is certain, and matching.estimate_pose runs essential-matrix RANSAC on them, many image pairs per call, with no copy to
the CPU. Like the models it has a portable (plain PyTorch) and a kernels (CUDA) backend.
| Solver | Runs on | Threshold (px) | Pose AUC@5 / @10 / @20 | Pairs per second |
|---|---|---|---|---|
| fastforks estimate_pose, kernels | GPU, batches of 500 pairs | 1.0 | 69.9 / 81.5 / 89.3 | 18,446 |
| fastforks estimate_pose, portable | GPU, batches of 500 pairs | 1.0 | 69.6 / 81.2 / 89.1 | 418 |
| PoseLib 2.0.5 | CPU, 16 processes | 1.0 | 70.0 / 81.6 / 89.5 | 325 |
| OpenCV USAC (MAGSAC++) | CPU, 16 processes | 0.5 | 65.7 / 78.6 / 87.3 | 271 |
| OpenCV RANSAC | CPU, 16 processes | 0.5 | 62.9 / 76.9 / 86.4 | 323 |
MegaDepth-1500, RoMa v2 matches (5000 per pair), 5 samplings, the same matches for every solver, on one machine: RTX 5060 Ti and a Ryzen 7 5800X (16 threads). Each solver runs at the inlier threshold where it is most accurate. Pairs per second is wall-clock throughput over all 7500 poses: the CPU solvers run one pair per call in 16 single-threaded processes, the GPU solver takes 500 pairs per call. One pair alone takes about 1.7 ms with the kernels, 29 ms with PoseLib and 24 ms with OpenCV RANSAC on one core. The accuracy table above stays on OpenCV RANSAC, as in the papers, so it is comparable with published numbers; this table is the only place the GPU solver is used.
Closeness to the original
Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 4.3e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.00079 and p99 <= 0.0042 (absolute error of the output warp).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.000043 | not recorded |
| gpu_min_score | ≤ 0.5 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.00079 | 0.00052 |
| GPU default dtypes, p99 |diff| | ≤ 0.0042 | 0.00269 |
Recorded for romav1 on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13, with these kernels: fastbb
Details
RoMa (Edstedt, Sun, Bökman, Wadenbäck, Felsberg, CVPR 2024): dense feature matching between two images of any viewpoint. A frozen DINOv2 ViT-L/14 and a VGG19-BN describe both images; a Gaussian process over the coarse DINOv2 features and a transformer classifier give a coarse warp, and convolutional refiners (local correlation at strides 16, 8, 4) sharpen it at strides 16 to 1, at a coarse square size and again at a fine size. Returns, for every pixel of the first image, its position in the second (pixels) and the probability that it is visible there.
- Input / output
- Input: two RGB images of one scene. Output: for every pixel of the first image its position in the second (x, y in pixels) and a certainty that the pixel is visible in both.
What the numbers mean, and which models need the camera focal length
Sparse matchers (LightGlue) return the keypoints of both images and the index pairs of the matched ones instead. To reconstruct camera poses from an image folder with these matchers, see [structure from motion](../sfm.md).
- Input size
- any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (1,989 MiB allocated)
- Options
coarse_size=560>= 14· changes the outputfine_size=864>= 0· changes the output
- Outputs
warp,certainty- CUDA kernels
fastbbfast backbone kernels: flash attention, window attention, instance norm and rotary embeddings for ViT and similar backbones
- Apple (MPS)
- fp32
Limitations
- One direction (the first image's half of upstream's symmetric call); upstream's sampling / keypoint helpers are not included; tools/eval_matching.py has the MegaDepth-1500 sampling.
- Both images are resized to squares (upstream's behaviour), whatever their aspect ratio; upstream resizes PIL images, this runner float tensors (bicubic, antialiased).
Full reference, generated from the repository
RoMa (2024): dense matching between two photos of one scene from any viewpoints: where each pixel of the first image is in the second, and how sure the model is that it is visible there. Built on Meta's DINOv2 and a VGG19. MIT code and weights; the DINOv2 weights are Apache-2.0.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
romav1 | synthetic (768x1024) | original portable kernels portable + torch.compile TensorRT fp16 | 386 377 356 247 planned for 0.2.1 | 3887 / 4094 1720 / 1840 1720 / 1860 1348 / 1476 – |
Details
- Original code: https://github.com/Parskatt/RoMa at
77f8d6880352 - Code licence: MIT (permissive); files:
LICENSE - Weights licence: MIT AND Apache-2.0
- Licence evidence: https://github.com/Parskatt/RoMa/blob/77f8d68803526dcddfd9b7a46bc76125bdc25f15/README.md#license
- Training data: MegaDepth (Internet photo collections with SfM / MVS depth) (roma_outdoor: MegaDepth (upstream README / paper). The frozen DINOv2 was pretrained on LVD-142M (not released).)
- Licence note: The DINOv2 ViT-L/14 weights are the second weight file (Meta's release, Apache-2.0).
- Options:
coarse_size= 560 (>= 14),fine_size= 864 (>= 0) - Kernel libraries:
fastbb - Variants:
romav1 - Not in this release (planned for 0.2.1):
romav1ONNX / TensorRT export: the ONNX converter fails on the exported program (ConversionError, step 3/3) - Outputs: warp, certainty
- Input size: any H x W >= 32, padded to a multiple of 32
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
romav13000x4000 (1.9 GiB peak allocated, 2.2 reserved) romav1768x1024, first call: portable + torch.compile 698 s (cold Inductor cache).romav1original 768x1024: the authors' mixed-precision option (float16); upstream RoMa v1 match, one direction; local correlation: upstream's plain-torch path (use_custom_corr off)romav1load / first call: original 6.28 s / 2.57 s, portable 2.34 s / 0.918 s, kernels 3.17 s / 1.026 s- Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5
Measured
Dense matchers: 5000 matches per pair sampled from the warp by certainty (upstream's balanced KDE sampling); sparse matchers: all their matches of one call (LightGlue, XFeat: LightGlue's MegaDepth-1500 setting; LoFTR, DeDoDe: their card defaults). OpenCV essential-matrix RANSAC (0.5 px threshold, normalised by the mean focal length); AUC of the larger of the rotation and translation-direction errors. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
romav1 | MegaDepth-1500, relative pose AUC@5 / @10 / @20 degrees | 62.6 / 76.6 / 86.3 | 62.6 / 76.6 / 86.4 | 62.4 / 76.4 / 86.2 | |||
romav1 | MegaDepth-1500, every 10th pair, relative pose AUC@5 / @10 / @20 degrees | 67.6 / 80.1 / 88.2 | 66.4 / 79.5 / 88.1 | 68.2 / 80.8 / 88.8 | 66.5 / 79.7 / 88.0 | 67.5 / 80.0 / 88.2 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f218aa9d, 2026-11-13.
Parity
CPU, float32: max |diff| <= 4.3e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.00079 and p99 <= 0.0042 (absolute error of the output warp).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
romav1 | 0.00052 / 0.00269 | RTX 5060 Ti, torch 2.14.1+cu130 | fastbb@7d058322634d:sm_120 |
Limitations
- One direction (the first image's half of upstream's symmetric call); upstream's sampling / keypoint helpers are not included; tools/eval_matching.py has the MegaDepth-1500 sampling.
- Both images are resized to squares (upstream's behaviour), whatever their aspect ratio; upstream resizes PIL images, this runner float tensors (bicubic, antialiased).
Example output
No example rendered for this checkpoint yet.