Kornia: Differentiable Computer Vision for PyTorch#
pip install kornia
Computer vision for
robotics & Spatial AI.
Why Kornia?
edges = kornia.filters.sobel(images.cuda()) # whole batch, one call
Same code, any device. Operators run wherever the tensor lives — no flags, no per-image loops.
gradient descent on a homography
warped = warp_perspective(src, H, size)
loss = (warped - dst).abs().mean()
loss.backward(); optimizer.step()
repeat until aligned
Registration by pure gradient descent. Gradients flow through every operator, so vision ops can sit inside your model or your loss — no labels, no training data.
torch.onnx.export(kornia.color.RgbToGrayscale(), x, "gray.onnx", dynamo=False)
Export once, run anywhere ONNX Runtime does — chained with Hub-hosted operators into one graph.
Considering sponsoring? — Inquire now
Features#
1,200+ differentiable operators — functions and nn.Module layers, batched and
device-agnostic — across geometry, feature matching, filtering, color, augmentation, losses and pretrained
models. Six places to start below; the full map is the API reference.
Cameras, homographies, Lie groups, RANSAC, depth-to-3D — every transform differentiable, so a pose is something you optimise.
Detect with KeyNet, DISK or ALIKED, match with LightGlue or LoFTR — classical SIFT and HardNet are there too.
Canny, Sobel, Gaussian, bilateral and morphology, batched and differentiable — usable as a layer or inside a loss.
One sampled transform applied to image, mask, boxes and keypoints alike — on the GPU, in 2D or 3D.
YuNet faces, RT-DETR objects, SAM masks, DexiNed edges — one line to build, weights on first use.
Lab, HSV, YUV and color maps; CLAHE, histogram equalisation, gamma and contrast — all trainable.
Prefer to learn by example? Image matching, registration, stitching, denoising, face detection and visual prompting each walk through one task end to end — and Conventions & pitfalls is the one page to read before writing code.
Support
Sponsor