Kornia: an Open Source Differentiable Computer Vision Library for PyTorch
Edgar Riba, Dmytro Mishkin, Daniel Ponsa, Ethan Rublee, Gary Bradski
TL;DR
Kornia addresses the gap in PyTorch where standard computer vision algorithms are CPU-bound and non-differentiable, hindering integration into deep learning pipelines. The authors present Kornia, a PyTorch-based library of differentiable, GPU-accelerated operators and modules (color, filters, geometry, features, losses) that mirror OpenCV-like functionality and can be embedded as network layers. They demonstrate practical use cases including batch image processing benchmarks, image registration by gradient descent, multi-view depth estimation, and differentiable local-feature matching with adversarial attack demonstrations, illustrating the practicality and performance benefits of differentiable CV within DL workflows. The work emphasizes production readiness and scalability through batching, distributed execution, and PyTorch TorchScript integration, aiming to broaden adoption and collaboration in open-source CV within DL contexts.
Abstract
This work presents Kornia -- an open source computer vision library which consists of a set of differentiable routines and modules to solve generic computer vision problems. The package uses PyTorch as its main backend both for efficiency and to take advantage of the reverse-mode auto-differentiation to define and compute the gradient of complex functions. Inspired by OpenCV, Kornia is composed of a set of modules containing operators that can be inserted inside neural networks to train models to perform image transformations, camera calibration, epipolar geometry, and low level image processing techniques, such as filtering and edge detection that operate directly on high dimensional tensor representations. Examples of classical vision problems implemented using our framework are provided including a benchmark comparing to existing vision libraries.
