Repository navigation
Migrate to kornia 0.9.2 - #79
Conversation
- 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>
|
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 |
|
@gmberton what about as adding them as xfeat-kornia, alongside original? |
|
Ping? |
|
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. |
|
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>
|
@gmberton I trimmed to wrappers for the new version, and the speed wins from LoFTR and DeDoDe are kept. |
|
Thank you for the PR @ducha-aiki ! |
Moves vismatch from kornia
>=0.7.3,<0.8.3tokornia>=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
kornia>=0.9.2,<0.10, which needstorch>=2.5.1and Python 3.11+.requires-pythonis raised to 3.11, the 3.10 classifier is dropped and CI runs on 3.11.vismatch/kornia_compat.py(imported byvismatch): 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.3cap.kornia.core.Module/Tensor(aspanformer) andkornia.rgb_to_grayscale(imatch-toolbox doghardnet-nn).tests/test_kornia_compat.pycovers them.KeyError: 'spv_b_ids'.tensor_to_imageis imported fromkornia.imageinstead of a deprecated alias, and the obsoletekornia>=0.7.3version 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.
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.
main)The kornia 0.9.2 speed column was measured on kornia
mainat 69a236609, just before the release, which adds only kornia#6797 and kornia#6800.Tests
pytest tests -vv -rs --timeout=600on 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 .andruff format --check .pass.Written by Claude (Opus 5.5) on behalf of @ducha-aiki