Skip to content

Migrate to kornia 0.9.2 - #79

Merged
gmberton merged 4 commits into
gmberton:mainfrom
ducha-aiki:kornia-0.9.1
Nov 21, 2026
Merged

gmberton merged 4 commits into
gmberton:mainfrom
ducha-aiki:kornia-0.9.1

Conversation

@ducha-aiki

@ducha-aiki ducha-aiki commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Moves vismatch from kornia >=0.7.3,<0.8.3 to kornia>=0.9.2,<0.10. No matcher is swapped for a different implementation: every model keeps its current code, and only what kornia 0.9 requires is changed.

Changes

  • Requirements: kornia>=0.9.2,<0.10, which needs torch>=2.5.1 and Python 3.11+. requires-python is raised to 3.11, the 3.10 classifier is dropped and CI runs on 3.11.
  • vismatch/kornia_compat.py (imported by vismatch): the third-party submodules still import a few kornia names that kornia has since removed. The submodules stay unedited; this module restores only the names they actually use, each pointing at its current location:
    • kornia.utils.grid.create_meshgrid: LoFTR-family fine matching in aspanformer, eloftr, matchanything, matchformer, se2loftr, topicfm and minima-loftr. This was the reason for the <0.8.3 cap.
    • kornia.core.Module / Tensor (aspanformer) and kornia.rgb_to_grayscale (imatch-toolbox doghardnet-nn).
    • tests/test_kornia_compat.py covers them.
  • Fix needed on kornia 0.9: kornia now builds LoFTR in training mode, so vismatch puts it in eval mode after loading the weights. Without this, matching raised KeyError: 'spv_b_ids'.
  • Cleanup: tensor_to_image is imported from kornia.image instead of a deprecated alias, and the obsolete kornia>=0.7.3 version asserts are removed.

Results

HPatches viewpoint pairs (the 145 pairs of the val split of HPatchesSeq-ransac-tutorial), RTX 4090, torch 2.15 + CUDA 13.2. Before = main + kornia 0.8.2, after = kornia 0.9.2 (PyPI), for matchers whose vismatch code this PR does not change.

Accuracy: share of pairs whose homography has mean corner error ≤ 1 / 3 / 5 px, and median error in px.

matcher before acc@1/3/5 after acc@1/3/5 median err before → after
sift-lightglue 0.441 / 0.724 / 0.834 0.448 / 0.710 / 0.828 1.26 → 1.28
doghardnet-lightglue 0.386 / 0.669 / 0.855 0.393 / 0.683 / 0.848 1.51 → 1.47
superpoint-lightglue 0.421 / 0.703 / 0.779 0.407 / 0.703 / 0.793 1.53 → 1.59
dedode-lightglue 0.338 / 0.634 / 0.759 0.331 / 0.634 / 0.772 1.76 → 1.75
dedode-kornia 0.241 / 0.676 / 0.766 0.255 / 0.676 / 0.738 1.97 → 1.90
loftr 0.248 / 0.621 / 0.731 0.359 / 0.662 / 0.759 2.06 → 1.66
eloftr 0.393 / 0.634 / 0.766 0.393 / 0.634 / 0.766 1.55 → 1.55

Each setup gives the same numbers on every run. The small differences come from kornia itself. For example, rgb_to_grayscale, used by the official LightGlue extractors, now rounds about a fifth of pixels differently in the last float32 bit. That moves a few keypoints at the detection threshold, and RANSAC then picks a slightly different homography.

Speed: full call (images to matches and RANSAC), ms per pair, median over 40 preloaded pairs, 2 processes × 3 rounds per setup, run alternately in one session. The same setup can vary by up to ±15% from one process to the next, so changes of a few percent are noise.

matcher kornia 0.8.2 (main) kornia 0.9.2 change
sift-lightglue 110 111 +1%
doghardnet-lightglue 110 101 −8%
superpoint-lightglue 35 37 +4%
dedode-lightglue 192 188 −2%
dedode-kornia 474 271 −43%
loftr 250 133 −47%
eloftr 314 300 −4%

The kornia 0.9.2 speed column was measured on kornia main at 69a236609, just before the release, which adds only kornia#6797 and kornia#6800.

Tests

  • pytest tests -vv -rs --timeout=600 on CUDA with kornia 0.9.2: 342 passed, 16 skipped. Every skip is an optional dependency that isn't installed (tensorflow for omniglue and zippypoint, torch_geometric for the sphereglue matchers).
  • ruff check . and ruff format --check . pass.

Written by Claude (Opus 5.5) on behalf of @ducha-aiki

ducha-aiki and others added 3 commits November 14, 2026 13:08
- Require kornia>=0.9.1, which needs torch>=2.5.1 and Python>=3.11: bump
  requires-python, drop the 3.10 classifier and run CI on 3.11.
- Add vismatch/kornia_compat.py, imported by vismatch, which re-registers the
  kornia names that third-party submodules still use but kornia removed:
  kornia.utils.grid (LoFTR-family fine matching in aspanformer, eloftr,
  matchanything, matchformer, se2loftr, topicfm, minima-loftr),
  kornia.utils.helpers, kornia.core.Module/Tensor and kornia.rgb_to_grayscale.
- Use kornia's implementations where the whole model is in kornia:
  xfeat, xfeat-star and xfeat-lightglue (KF.XFeat + LightGlueMatcher("xfeat"),
  which now also returns match confidences), disk-lightglue and
  aliked-lightglue (kornia extractors + LightGlueMatcher, keeping the official
  1024 px long-side resize). superpoint-, sift- and doghardnet-lightglue keep
  the official LightGlue code (no SuperPoint in kornia; OpenCV SIFT detector).
- Import tensor_to_image from kornia.image instead of deprecated aliases, and
  drop the obsolete kornia>=0.7.3 version asserts.
kornia 0.9 builds LoFTR(pretrained=None) in training mode, where coarse matching reads
ground-truth keys and raised KeyError: 'spv_b_ids'; put the model in eval mode after loading
its weights. XFeat's _refine_matches reads the "cell_scales" that only _detect_dense returns,
so xfeat-star raised KeyError: 'cell_scales' with detectAndComputeDense; call _detect_dense.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kornia 0.9.1 made aliked-lightglue about 15% slower than with kornia 0.8.2;
0.9.2 brings it back (kornia #6779, #6780, #6781) and keeps HPatches results
identical to 0.9.1 for the other kornia-backed matchers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gmberton

Copy link
Copy Markdown
Owner

Thanks! Can you revert the xfeat and LightGlue changes? I don't want to swap a model for one that gives different results. And can you cap kornia>=0.9.2,<0.10 and trim kornia_compat.py to the names actually used? Dropping Python 3.10 is fine.

@ducha-aiki

ducha-aiki commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@gmberton what about as adding them as xfeat-kornia, alongside original?
I consider those as bugfix in original model, not as new, because nothing was trained, the weights are authors and we did just big fixes, which improve things a lot. And the paper did not describe specific behavior in nuances.

@ducha-aiki

Copy link
Copy Markdown
Contributor Author

Ping?

@gmberton

Copy link
Copy Markdown
Owner

I would generally avoid adding multiple versions for models (I did it in the past for many models and now regret it). Unless you think these models (with your edits) are now pareto optimal on any direction. Perhaps one of them could have the new *-kornia alternative, if pareto-optimal.
Let me know what you think, I'll rely on your judgement.

@ducha-aiki

Copy link
Copy Markdown
Contributor Author

None of them is pareto optimal, I just don't like Xfeat* to have 5% mAA, while it can be 27%, but I understand the maintenance. I will reduce PR for minimalistic case then

Per review: revert xfeat, xfeat-star, xfeat-lightglue, disk-lightglue and
aliked-lightglue (and the docs note) to their original implementations, so
no matcher is swapped for one with different results. Cap kornia at <0.10.
Trim kornia_compat to the names the submodules actually import: drop
create_meshgrid3d (unused) and kornia.utils.helpers (only MatchAnything's
hloc adalam matcher, which vismatch never imports).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ducha-aiki

Copy link
Copy Markdown
Contributor Author

@gmberton I trimmed to wrappers for the new version, and the speed wins from LoFTR and DeDoDe are kept.

@gmberton
gmberton merged commit f931d50 into gmberton:main Nov 21, 2026
2 checks passed
@gmberton

Copy link
Copy Markdown
Owner

Thank you for the PR @ducha-aiki !

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.

2 participants