Differentiable computer vision on PyTorch tensors · GPU & autograd · verified against Kornia 0.8 (2026)

Kornia cheat sheet

Kornia is a differentiable computer-vision library built on PyTorch: classic CV ops (filtering, color, geometry, features) that run on the GPU, work in batches, and are differentiable — so they slot into a training graph and you can backprop through them. Think "OpenCV/skimage as tensor ops". Everything operates on (B, C, H, W) float tensors in [0,1]. Highlights: GPU augmentation that keeps images/masks/boxes/keypoints in sync, and deep local-feature matching (LoFTR). Targets Kornia 0.8.

tensors & color augmentation filters & enhance geometry features & losses gotcha most common

Verified 2026-08-24 against the official docs at kornia.org / kornia.readthedocs.io and the kornia/kornia repo (0.8.x). Pure PyTorch — ops accept & return tensors, run on any device, and are autograd-compatible.

Outline

The whole library is tensor-in / tensor-out. The two things that make Kornia special: differentiable geometry and GPU augmentation that transforms labels alongside the image.

Basics

  1. 1 · Install & tensor format
  2. 2 · Color & conversions

Augment

  1. 3 · GPU augmentation
  2. 4 · AugmentationSequential (labels)

Process

  1. 5 · Filters & edges
  2. 6 · Enhance & morphology

Geometry

  1. 7 · Warps & transforms
  2. 8 · Differentiable geometry

Deep CV

  1. 9 · Features & matching
  2. 10 · Losses & models
  3. 11 · Gotchas
  4. Worth memorizing

Basics

The tensor contract, and getting images in/out.

1Install & tensor format0.8
2Color & conversionskornia.color

Augmentation

Batched, GPU, differentiable — and it transforms your labels too.

3GPU augmentationkornia.augmentation
4AugmentationSequential (labels)keep labels in sync

Process

Differentiable filtering and enhancement.

5Filters & edgeskornia.filters
6Enhance & morphologyadjust

Geometry

Kornia's core: warps you can differentiate through.

7Warps & transformskornia.geometry
8Differentiable geometryoptimize a transform

Deep CV

Local features, matching, and loss functions.

9Features & matchingkornia.feature
10Losses & modelskornia.losses
!Common gotchasread before shipping

Worth memorizing

tensor in, tensor out(B, C, H, W) float [0,1] — OpenCV/skimage as PyTorch ops
image_to_tensor / tensor_to_imageHWC uint8 ↔ CHW float bridge
augment on GPU in the loopkornia.augmentation modules, batched & random-per-sample
AugmentationSequential(data_keys=...)image + mask + bbox + keypoints transformed together
warps are differentiableoptimize a homography with backward() — image registration by SGD
get_perspective_transform + warp_perspectivefour point pairs → warp
LoFTR for deep matchingpretrained detector-free correspondences
ssim/dice/focal lossesready-made differentiable image & segmentation losses
no_grad for pure preprocessingops keep gradients by default