Source-linked AI summary

Kornia: an Open Source Differentiable Computer Vision Library for PyTorch

Edgar Riba, Dmytro Mishkin, Daniel Ponsa, Ethan Rublee, Gary Bradski

arXiv:1910.02190v2cs.CV

TL;DR

Kornia addresses the gap between CPU-oriented vision libraries and GPU-based deep-learning workflows by providing differentiable computer-vision operators within PyTorch. It implements classical vision functions that can run on tensors and be embedded in neural networks, while supporting high-performance processing and comparable performance to existing libraries.

  • Problem

    Existing computer-vision libraries are largely optimized for CPUs, while deep-learning algorithms increasingly process images in parallel on GPUs, motivating PyTorch-based vision tools.

  • Method

    Kornia provides OpenCV-inspired computer-vision functions as differentiable PyTorch operators that run on tensors, support GPU acceleration, and can be embedded as neural-network layers.

  • Results

    Kornia implements traditional vision algorithms in differentiable form and solves image registration, depth estimation, and local-feature matching with performance similar to existing libraries.

  • Takeaways & Limitations

    Kornia enables classical computer-vision libraries to serve as components of deep-learning networks and as preprocessing or postprocessing modules.

  • Takeaways & Limitations

    Kornia operators assume batched N-channel image tensors rather than standard single 1–3-channel images, constraining the input format despite supporting multispectral and hyperspectral data directly.

Abstract

from arXiv · show

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.

1. Introduction

Kornia addresses PyTorch’s lack of standard GPU-native vision algorithms by providing differentiable computer vision routines that can run inside deep networks. The library combines PyTorch properties with an OpenCV-inspired computer vision interface and demonstrates applications including image registration, depth estimation, and local feature detection.

  • PyTorch lacked standard vision algorithms that could run directly on GPUs using native tensor data structures.
  • Kornia is an open-source PyTorch library providing GPU-implemented image-processing functions that can be embedded inside deep networks.
  • Kornia combines OpenCV-inspired computer vision interfaces with PyTorch differentiability, GPU acceleration, and distributed data flows.
  • The paper demonstrates Kornia on image registration, depth estimation, and local feature detection tasks.

2. Related work

The related-work review contrasts traditional CPU-oriented computer vision libraries with deep-learning frameworks and motivates a PyTorch-native alternative. Kornia is presented as filling this ecosystem gap with differentiable, batched, device-transparent, distributed, and production-ready vision algorithms.

  • Traditional computer vision libraries such as OpenCV and VLFeat primarily provided open-source algorithms optimized for CPU execution.
  • Table 1 identifies Kornia and tensorflow.image as the only listed frameworks that mostly support GPU execution, batched data, differentiability, and distributed computation.
  • Deep learning shifted substantial vision computation toward GPUs, while libraries such as OpenCV and PIL remained common for CPU preprocessing and postprocessing.
  • Kornia fills a PyTorch ecosystem gap by implementing standard vision algorithms with differentiability, CPU/GPU transparency, distributed computation, and production-oriented code.

3. Kornia: Computer Vision for PyTorch.

Kornia provides high-level computer vision operators over PyTorch tensors, inheriting automatic differentiation, device execution, parallelism, distributed processing, and production tooling. Its modules cover color, filtering, features, geometry, transformations, cameras, losses, and tensor utilities.

  • Kornia lets users write high-level vision algorithms on PyTorch tensors while supporting automatic differentiation, CPU/GPU execution, parallelism, distributed processing, and production deployment.
  • Differentiable: Differentiable vision functions can serve as neural-network layers because reverse-mode autodifferentiation computes gradients through their operator graphs.
  • Transparent API: The device-agnostic API runs algorithms on either CPU or GPU, while batch processing applies operators to N-channel image tensors by default.
  • Kornia’s modules include color conversion, filtering, local features and matching, geometric transformations, camera models, coordinate conversions, losses, and tensor utilities.
  • The library also provides linear-algebra routines, homography- or depth-based warping, vision losses, and experimental tensor operators.

4. Use cases

Kornia demonstrates differentiable, PyTorch-integrated solutions for classical vision tasks, including image processing, geometric registration, multi-view depth estimation, and local-feature matching. Its examples combine gradient-based optimization with GPU-compatible operators and show competitive batch-processing performance, especially on GPUs.

  • Library capabilities: Kornia provides differentiable operators for low-level image processing, geometric transformations, image registration, depth estimation, and local-feature detection and matching.These operators can be embedded with other PyTorch components and used in parallel or distributed computation.
  • Batch image processing: Kornia’s batch Sobel benchmark is similar to other libraries for small batches, while its GPU implementation achieves the best timing for large batches.The comparison uses 256x256 RGB images, varying batch sizes, and median elapsed time over 500 runs.
  • Image registration: Image registration optimizes homography parameters by minimizing photometric error across a multi-resolution pyramid using gradient descent and PyTorch Autograd.Optimization proceeds from lower to upper resolutions, with Adam using a 1e-3 learning rate and 200 iterations per scale level.
  • Multi-view depth estimation: Multi-view depth estimation solves for a reference-view depth image by warping calibrated views through differentiable bilinear sampling and minimizing photometric and smoothness losses.The pipeline accepts an arbitrary number of calibrated camera views and uses multi-scale pyramids with classical loss formulations.
  • Multi-view depth estimation: The multi-view pipeline addresses limitations of existing learning approaches by supporting arbitrary view counts and camera configurations without requiring ground-truth depth.The authors contrast it with methods limited to stereo, low-resolution datasets, or high-quality ground-truth depth.
  • Local-feature matching: Kornia’s differentiable local-feature tools support a targeted adversarial attack that optimizes initially nonmatching images to produce matching Hessian-detector and SIFT features surviving RANSAC verification.The example uses the differentiability of local feature detection and description in a wide-baseline matching pipeline.

5. Conclusions

Kornia brings traditional computer vision algorithms into PyTorch as differentiable, hardware-accelerated components. The paper demonstrates classical vision problems solved with performance similar to existing libraries and envisions their use within deep learning networks.

  • Kornia implements traditional vision algorithms in a differentiable fashion within PyTorch, using hardware acceleration to improve performance.
  • The library supports classical problems including image registration by homography, depth estimation, and local feature matching.
  • The authors report that these classical vision problems can be solved easily with performance similar to existing libraries.
  • Kornia is intended to let classical computer vision libraries function as network layers and as pre- and post-processing components in deep learning environments.
Loading 1910.02190v2…