# Kornia

> Differentiable computer vision and geometry operators for PyTorch

- Category: Multimodal Generation / Vision & Understanding
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/kornia/kornia
- Website: https://kornia.readthedocs.io
- Canonical page: https://ai-tldr.dev/tools/kornia/

## In short

Kornia is a differentiable computer vision library built on top of PyTorch. It sits in the Vision & Understanding category of the Multimodal Generation tools and is open-source, written in Python and licensed Apache-2.0. To get started: install from pip.

## Overview

Kornia is a differentiable computer vision library built on top of PyTorch. Every operator — filters, colour conversions, affine and homography warps, edge detectors, morphology, photometric losses — is written as a differentiable tensor op, so it runs batched on the GPU and gradients flow through it. That is the difference from a classical CV library: instead of calling out to an opaque image routine and breaking the graph, the vision step becomes part of the network you are training.

Beyond low-level operators, the library ships augmentation pipelines (AugmentationSequential, PatchSequential, VideoSequential, plus AutoAugment, RandAugment and TrivialAugment), a geometry stack covering camera models and calibration, epipolar geometry, homography estimation, depth from disparity and Lie groups, and a set of pre-trained models reachable from the same API — YuNet for face detection, LoFTR and LightGlue for feature matching, DISK, DeDoDe and SOLD2 descriptors, SAM for segmentation and MobileViT/VisionTransformer for classification. The project counts more than 500 operators in total.

Kornia is developed and maintained by volunteers and published under Apache 2.0. Its stated direction is to be the reference implementation and executable specification for differentiable computer vision and geometry in the PyTorch ecosystem — explicit conventions, conformance tests and published benchmarks rather than API growth. The repository documents half-precision support module by module, with a table of float16 and bfloat16 pass rates that contributors can reproduce locally.

## What it does

- 500+ differentiable operators: filters, colour conversions, geometric transforms, edge detection, morphology, losses and metrics
- Batched and GPU-accelerated through PyTorch, with autograd flowing through every vision step
- Augmentation pipelines — AugmentationSequential, PatchSequential, VideoSequential — plus AutoAugment, RandAugment and TrivialAugment
- Geometry stack: camera models and calibration, epipolar geometry, homography estimation, depth from disparity, Lie groups, PnP solvers
- Pre-trained models behind the same API: YuNet, LoFTR, LightGlue, DISK, DeDoDe, SOLD2, SAM, MobileViT, VisionTransformer
- Documented float16 / bfloat16 support per module, with reproducible pass-rate tables

## Getting started

Kornia is a pure PyTorch dependency — install it next to your existing model code. All commands below come from the project README.

1. Install from pip

   Kornia requires PyTorch 2.5.1 or newer. Some features (ONNX, Stable Diffusion dissolving) need optional extras, listed in the installation docs.

```bash
pip install kornia
```

2. Try it without installing anything

   The project hosts a browser playground and a hello-world Colab notebook, both linked from the README, so you can run operators before adding the dependency.

```text
https://www.kornia.org/playground/
```

3. Work through the tutorials

   The tutorials site and the kornia-examples repository walk through augmentation, feature matching and geometry task by task.

```text
https://www.kornia.org/tutorials/
```

4. Install in editable mode to hack on it

   Clone the repository and install it editable when you want to change operators or add tests.

```bash
pip install -e .
```

5. Reproduce the precision benchmarks

   Development uses pixi for environment management; these two tasks regenerate the float32 baseline and the half-precision rows of the support table.

```bash
pixi run test-f32
pixi run test-half
```

## When to use it

- Reach for it when an image operation has to sit inside the training graph and stay differentiable
- Reach for it when you need GPU-batched augmentation that behaves identically on images, patches and video
- Reach for it for classical geometry — calibration, homography, epipolar, PnP — expressed as tensor ops next to your model
- Reach for it when you want feature matching (LoFTR, LightGlue) or segmentation (SAM) without wiring a separate inference stack
