XFeat (fastforks)

XFeat (Potje et al., CVPR 2024): lightweight sparse feature matching. A small CNN finds up to 4096 keypoints per image with 64-dimensional descriptors; they are matched as mutual nearest neighbours or with LighterGlue, a smaller LightGlue trained for XFeat. Returns both keypoint sets, the index pairs of the matches and their confidence.

This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/verlab/accelerated_features at e92685f57f83.

Task: matching. Tier: experimental. Outputs: keypoints1, keypoints2, pairs, scores. Backends: portable.

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. 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.

Variants

Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.

variant weights (author link) SHA-256 weights licence commercial use
xfeat@1 xfeat.pt 0f5187fd7bed Apache-2.0 yes
xfeat-lighterglue@1 xfeat.pt
xfeat-lighterglue.pt
0f5187fd7bed
766102df37f1
Apache-2.0 yes

Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: LICENSE.

Training data: MegaDepth (Internet photo collections with SfM / MVS depth), COCO 2017 (train, instance annotations) (XFeat: MegaDepth and synthetic warps of a 20k-image COCO 2017 subset (README training section). LighterGlue: trained with GlueFactory (README; MegaDepth, data not otherwise stated).).

Licence evidence: https://github.com/verlab/accelerated_features/blob/e92685f57f8318b18725c5c8c0bd28c7fe188d9a/LICENSE ; https://github.com/verlab/accelerated_features/blob/e92685f57f8318b18725c5c8c0bd28c7fe188d9a/README.md#license

Input size

any H x W >= 32, padded to a multiple of 32 Tested up to (portable, fp16, RTX 5060 Ti 16 GB): xfeat 3000x4000 (1.0 GiB peak allocated, 1.2 reserved); xfeat-lighterglue 3000x4000 (1.0 GiB peak allocated, 1.2 reserved)

Speed and memory

Matching, synthetic, 768x1024

model time (ms): original fp32 original portable kernels kernels speed-up: vs original vs portable peak memory (MiB, allocated / reserved): original portable kernels
xfeat – 8.89 7.17 – – – 128 / 174 122 / 154 –
xfeat-lighterglue – 23.6 21.6 – – – 448 / 478 445 / 476 –

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
xfeat 1.51 0.16 – 0.63 0.74 –
xfeat-lighterglue 1.46 0.25 – 0.69 0.68 –

torch.compile and TensorRT

model input time: portable compile TensorRT fp16 kernels preparation: compile (cold first call) ONNX + engine build peak MiB (alloc / reserved): portable compile kernels TensorRT (engine + torch)
xfeat 768x1024 7.17 ms 5.65 ms planned for 0.2.1 – 30.8 s – 122 / 154 186 / 212 – –
xfeat-lighterglue 768x1024 21.6 ms 16.2 ms planned for 0.2.1 – 39.7 s – 445 / 476 262 / 278 – –

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.

Accuracy

On public datasets

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. The same 300 pairs for all modes, so float32 and bfloat16 compare pair for pair. Original = the original code named under Details, same checkpoint and protocol.

variant dataset original fp32 original fp16 portable note
xfeat MegaDepth-1500, relative pose AUC@5 / @10 / @20 degrees 26.2 / 42.2 / 57.5
xfeat MegaDepth-1500, every 5th pair, relative pose AUC@5 / @10 / @20 degrees 29.1 / 46.1 / 60.8 28.4 / 44.6 / 60.1 29.1 / 46.1 / 60.8
xfeat-lighterglue MegaDepth-1500, relative pose AUC@5 / @10 / @20 degrees 39.7 / 57.5 / 72.8
xfeat-lighterglue MegaDepth-1500, every 5th pair, relative pose AUC@5 / @10 / @20 degrees 42.0 / 59.4 / 74.3 42.7 / 60.1 / 74.1 42.0 / 59.4 / 74.3

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks ec7b1307+port/p1-match, 2026-11-12.

Parity with the original code

Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 3e-05 vs the original. GPU, portable float32 and kernels float16 (the defaults): mean |diff| <= 0.0001 and p99 <= 0.001 (absolute error of the output keypoints1).

Limitations

  • Sparse output: no dense warp. result.matches() gives the matched points for estimate_pose; pairs are the index pairs pycolmap / COLMAP databases take.
  • One image pair per call internally (batches run pair by pair); the keypoint counts differ per image.
  • No exportable module: the keypoint counts are data-dependent (torch.compile runs with graph breaks; ONNX / TensorRT export fails).
  • xfeat (mutual nearest neighbours) has no learned confidence: its scores are the descriptors' cosine similarities.

Usage

from fastforks import matching

model = matching.load("xfeat")  # mode="auto": the preferred backend from recorded measurements
result = model("view1.jpg", "view2.jpg")
result.keypoints1, result.keypoints2, result.pairs  # [N, 2], [M, 2] pixels; [K, 2] int64 index pairs
result.backend  # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')

Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: xfeat, xfeat-lighterglue.

Kernels backend

No kernels backend: not implemented: data-dependent keypoint counts (NMS, top-k, match filtering); the extractor is a small CNN.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including fastforks/xfeat