█

AI/TLDR

Buy me a coffee
Buy me a coffee

Kornia

Differentiable computer vision and geometry operators for PyTorch

Vision & UnderstandingOpen source
Language
Python
License
Apache-2.0
$pip install kornia
IN SHORT

What is Kornia?

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.

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.

bashbash
pip install kornia

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.

texttext
https://www.kornia.org/playground/

Work through the tutorials

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

texttext
https://www.kornia.org/tutorials/

Install in editable mode to hack on it

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

bashbash
pip install -e .

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.

bashbash
pixi run test-f32
pixi run test-half

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

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

How Kornia compares

Kornia alongside other open-source vision & understanding tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
PaddleOCR★ 93.5kA toolkit for detecting and recognizing text in images across many languages, plus document parsing.
OpenCV★ 91.8kThe long-standing open-source computer-vision library for C++, Python and Java; version 5 rewrote the DNN engine and added ONNX-based LLM and VLM inference in-library.
Ultralytics YOLO★ 63.9kA framework for training and running YOLO models for real-time object detection, segmentation, and tracking.
YOLOv5★ 58.3kUltralytics' PyTorch repo for training, running and exporting YOLOv5 object-detection, instance-segmentation and classification models with plain scripts and PyTorch Hub.
Supervision★ 51.8kA Python toolkit for processing, annotating, and visualizing detections and segmentations from many vision models.
MediaPipe★ 38kGoogle's on-device ML framework: ready-to-run vision, text and audio tasks with one cross-platform API for Android, iOS, web, desktop and edge.
MMDetection★ 33.1kAn OpenMMLab toolbox with many object detection and instance segmentation algorithms for research and production.
Kornia★ 12.5kDifferentiable computer vision and geometry operators for PyTorch