Kornia provides GPU-friendly, differentiable image processing and geometry operators built on PyTorch. It spans augmentation, feature matching, camera models, and pretrained vision models.
Overview
Kornia is a Python library for geometric computer vision and spatial AI workflows inside PyTorch. Operators run on the same device as input tensors, support batching with per-sample parameters, and participate in autograd so vision steps can sit inside models or losses.
Coverage includes filtering, color transforms, edge detection, morphology, warps and homographies, epipolar geometry, minimal solvers, RANSAC on device, Lie groups, depth-to-3D utilities, and augmentation pipelines that keep images, masks, boxes, and keypoints aligned. Learned matchers such as LoFTR and LightGlue and classical SIFT-style tooling live alongside pretrained detectors and segmenters.
The project emphasizes conventions, conformance tests, and published benchmarks against CPU libraries and torchvision where overlap exists. Many operators export to ONNX and run under torch.compile on supported PyTorch versions. CPU, CUDA, and MPS tensors are supported with documented half-precision limits.
Install via pip, with optional extras for ONNX and related features. A separate kornia-rs project targets edge devices. Sponsorship and community contributions sustain ongoing maintenance.
Key features
- Differentiable image filters and warps
- Batched geometry solvers and RANSAC
- AugmentationSequential for labels
- Feature detectors and matchers
- Camera models and depth unprojection
- Pretrained vision model wrappers
- ONNX export for many operators
- torch.compile compatibility
Use cases
- End-to-end trainable registration
- GPU batch augmentation for training
- Robotics and spatial AI pipelines
- Differentiable homography optimization
- ONNX deployment of vision chains