# Kornia: Differentiable Computer Vision for PyTorch with 500+ Operations

> Kornia is an open-source Python library that provides differentiable image processing and geometric computer vision algorithms built on PyTorch. It covers augmentation pipelines, geometric transformations, feature detection, and pre-trained vision models, all with gradient support for integration into deep learning training loops.

**kornia/kornia** — 🐍 Geometric Computer Vision Library for Spatial AI

- Repository: https://github.com/kornia/kornia
- Website: https://kornia.readthedocs.io
- Stars: 11,390 · Forks: 1,344
- Language: Python
- License: Apache-2.0
- Published: 2026-09-10 · Updated: 2026-09-10 · Language: en
- Canonical page: https://hysenlabs.com/projects/kornia-kornia

## What kornia solves and who uses it

Differentiable computer vision describes the ability to apply image processing and geometric operations as layers in a neural network, with gradients flowing backward through those operations during training. Without a library like Kornia, engineers working in PyTorch must either implement these operations themselves, accept that preprocessing steps are non-differentiable, or use wrappers around OpenCV that break the gradient graph.

Kornia addresses this gap. Its primary users are machine learning engineers and researchers who build vision models with PyTorch and need augmentation, geometric warping, feature detection, or photometric operations to participate in the gradient computation graph. The library is also used for post-processing pipelines where GPU acceleration matters and the PyTorch tensor format is already established.

The project description from the repository is 'Geometric Computer Vision Library for Spatial AI', which signals that the core focus is on spatial operations: coordinate transformations, homographies, camera models, stereo vision, and 3D geometry. The augmentation pipeline covers a broad range of image-level operations, but the deeper specialization is geometric: the set of operations that require precise mathematical formulations and explicit treatment of camera geometry.

## Architecture: PyTorch-native differentiable operations at scale

Kornia is structured as a Python package built on top of PyTorch, with a companion Rust component called kornia-rs (kornia_rs in Python) that provides low-level image I/O. The pyproject.toml lists dependencies as kornia_rs>=0.1.14, numpy>=1.21, and torch>=2.5.1, meaning a working Kornia installation requires a recent PyTorch version.

The library is organized into functional modules covering image processing (filters, color conversions, enhancements), augmentations (AugmentationSequential, PatchSequential, VideoSequential, AutoAugment, RandAugment, TrivialAugment), feature detection and description (Harris, GFTT, Hessian, DISK, DeDoDe, HardNet, SIFT, LightGlue, LoFTR), geometry (camera models, homography estimation, stereo vision, 3D transformations), and deep learning layers including loss functions like SSIM and PSNR.

All operations return PyTorch tensors and support batch processing. The README states that Kornia provides 'powerful batch transformations, auto-differentiation and GPU acceleration'. The ROADMAP.md sets the project's direction as becoming the reference implementation and executable specification for differentiable computer vision in the PyTorch ecosystem, with explicit conventions, conformance tests, and benchmarks as the defining properties.

The project also ships pre-trained models as part of the library: YuNet for face detection, LoFTR and LightGlue for feature matching, DISK and DeDoDe for feature description, SAM for segmentation, and MobileViT and VisionTransformer for classification. Having these models directly in the kornia namespace reduces integration work for users who need them as components inside a larger pipeline.

## Installing kornia and running augmentations

The standard installation is through PyPI. The pyproject.toml confirms the package name is `kornia`:

```bash
pip install kornia
```

The package requires Python 3.11, 3.12, or 3.13, and torch 2.5.1 or higher. Installing in an environment with an older PyTorch version will fail the dependency check. The project uses pixi and uv for its own development environment, but standard pip works for end users.

The pyproject.toml also defines optional dependencies for development (coverage, pillow, pre-commit, pytest), documentation (pydata-sphinx-theme, sphinx), and ONNX export. Install the base package for use in a model; add the optional groups only for contributing to the project or exporting models.

Kornia exposes a Playground at www.kornia.org/playground/ for trying operations in the browser without installation. The README links to tutorials and a collection of examples in the kornia-examples repository on GitHub. The documentation is at kornia.readthedocs.io.

## The augmentation pipeline and its constraints

Kornia's augmentation pipeline covers a wide range of standard transforms: random cropping, erasing, affine warps, flipping, fish-eye distortion, perspective, elastic transforms, Gaussian and motion blur, rain, snow, salt-and-pepper noise, contrast, brightness, CLAHE, hue, saturation, MixUp, CutMix, Mosaic, and more. AugmentationSequential composes these operations in sequence, with support for applying the same random parameters to image-label pairs for supervised training.

A real constraint: because all augmentations are implemented as PyTorch modules and return tensors, they require input in PyTorch tensor format. Teams whose data pipelines produce NumPy arrays or PIL images need an explicit conversion step before using Kornia augmentations. Libraries like albumentations work directly with NumPy arrays, which can be more convenient in preprocessing pipelines that do not run on GPU.

Another constraint is the Python version floor. The 3.11 minimum reflects torch 2.5.1's own requirements. Projects that must support Python 3.9 or 3.10 for deployment reasons cannot use current Kornia releases.

The v0.9.0rc1 release note, published 2026-07-19, is described as 'compile-first, deployable augmentations', indicating that the project is working on making the augmentation pipeline compatible with torch.compile for compiled model deployment. This is active work, and the 0.9.x API may change before a stable release.

## Kornia versus albumentations and opencv-python

Albumentations is the most commonly used alternative for image augmentation in Python. It operates on NumPy arrays, supports a broad set of transforms, integrates with PyTorch and TensorFlow data loaders through its ToTensorV2 transform, and has no PyTorch version dependency. The key distinction: albumentations augmentations are not differentiable. They run in CPU memory and break the gradient graph. For teams that only need augmentation as a data preprocessing step before a training forward pass, albumentations is lighter to install and compatible with more Python versions.

OpenCV-python (cv2) is a C-backed Python library covering almost every classical computer vision algorithm. It is not differentiable, does not produce PyTorch tensors natively, and does not have the batch processing model that Kornia provides. OpenCV is the right choice for applications that run on CPU, need to interface with video streams, or need operations that Kornia does not cover. For gradient-based optimization or for operations that need to run inside a torch.compile graph, Kornia is the correct choice over OpenCV.

Kornia's own ROADMAP.md mentions a goal of providing honest benchmarks comparing Kornia operations to alternatives, which suggests the project acknowledges the performance trade-off: differentiability adds computational overhead compared to non-differentiable CPU implementations.

## Maintenance, license, and the kornia-rs dependency

The last push to the Kornia repository was on 2026-09-27, and the project is not archived. The latest stable release is v0.8.3 from 2026-05-19, with v0.9.0rc1 available for testing. The license is Apache-2.0, which permits commercial use, modification, and distribution without requiring that derived works be open-sourced.

The dependency on kornia_rs is a Rust-compiled package. In most environments, this installs from a pre-built wheel on PyPI without requiring a Rust toolchain. If a matching pre-built wheel is not available for a platform or Python version, the install will either fail or require building from source. This is a practical concern for unusual deployment targets such as ARM-based systems or Python versions not yet covered by the wheel matrix.

The pyproject.toml classifies the project as Development Status 4 - Beta, which is an honest signal: the API is usable and tested, but the project's stated goal of becoming a conformance-focused reference implementation means some API changes are expected as explicit conventions are codified.

## Conclusion

Kornia is the right choice for teams building PyTorch training pipelines that need differentiable augmentation, geometric transformations, or classical vision algorithms with gradient support. It requires Python 3.11 or higher and torch 2.5.1 or higher. Teams that primarily need fast CPU-based augmentation without differentiability should evaluate albumentations, which carries a lighter dependency and broader Python version compatibility. Verify the ROADMAP.md in the repository before committing to any API that is marked as in flux, since the project's stated direction prioritizes conformance and explicit conventions over backward compatibility during its current phase.

## FAQ

### How do I install kornia?

Run `pip install kornia` in a Python 3.11+ environment with torch 2.5.1 or higher already installed. The package is on PyPI.

### What is kornia?

Kornia is an open-source PyTorch library providing differentiable computer vision algorithms including image filters, augmentations, geometric transformations, feature detection, and pre-trained models for tasks like face detection, feature matching, and segmentation.

### How does kornia compare to albumentations?

Kornia augmentations are differentiable PyTorch modules that preserve gradients and run on GPU, while albumentations operates on NumPy arrays without differentiability. Albumentations requires no PyTorch dependency and works with Python 3.9+, making it lighter for pure preprocessing pipelines.

### How does kornia compare to OpenCV?

Kornia is a PyTorch-native library with gradient support and batch processing; OpenCV is a C-backed library operating in CPU memory without PyTorch integration. Kornia is the right choice when operations need to participate in gradient computation or run inside a PyTorch training loop.

## Sources

- [kornia/kornia on GitHub](https://github.com/kornia/kornia)
- [License: Apache-2.0](https://github.com/kornia/kornia/blob/main/LICENSE)
- [Project website](https://kornia.readthedocs.io)
- [README](https://github.com/kornia/kornia/blob/main/README.md)
- [Releases](https://github.com/kornia/kornia/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/kornia-kornia
