Registry / ai-ml / kornia-rs

kornia-rs

JSON →
library0.1.14pypypi✓ verified 24d ago

Kornia-rs is a low-level computer vision library primarily written in Rust, offering high-performance image I/O, processing, and 3D operations through Python bindings. It leverages Rust's memory safety and speed for demanding computer vision tasks, integrating efficiently into machine learning and data science workflows via zero-copy data transfer with frameworks like NumPy and PyTorch. The library is actively developed by the Kornia organization and is currently at version 0.1.10.

pip install kornia-rs
INSTALL
IMPORT
SIG · KORNIA-RS
K
kornia-rs
ai-mlpythonv0.1.14
Install
1.7s avg
Import
Disk
23MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.14 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 26MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

kornia_rs
import kornia_rs as K
from kornia_rs import read_image_jpeg
While direct imports are possible, aliasing 'kornia_rs' as 'K' is a common convention demonstrated in official examples, allowing for a consistent API access pattern.

This quickstart demonstrates how to read an image using `kornia-rs`, convert the resulting `kornia_rs.Tensor` to a NumPy array via DLPack for seamless integration with Python data science tools, perform a basic image processing operation like resizing, and then convert the result back to a NumPy array. This highlights the library's high-performance I/O and interoperability.

import kornia_rs as K import numpy as np import os # For demonstration, create a dummy image file if it doesn't exist # In a real scenario, replace 'dummy.jpeg' with your image path. if not os.path.exists('dummy.jpeg'): try: from PIL import Image img = Image.new('RGB', (256, 256), color = 'red') img.save('dummy.jpeg') print("Created 'dummy.jpeg' for quickstart.") except ImportError: print("Pillow not installed. Skipping dummy image creation.") print("Please create a 'dummy.jpeg' file or adjust the quickstart path.") exit() # Or handle gracefully without exiting # 1. Read an image into a kornia_rs.Tensor # This uses the image-rs backend by default (or turbojpeg if enabled/available). image_tensor = K.read_image_jpeg('dummy.jpeg') print(f"Original image tensor shape: {image_tensor.shape}") # 2. Convert the kornia_rs.Tensor to a NumPy array (zero-copy via DLPack) np_image = np.from_dlpack(image_tensor) print(f"NumPy array shape: {np_image.shape}, dtype: {np_image.dtype}") # 3. Perform a basic image operation, e.g., resize # The resize function expects a kornia_rs.Tensor and returns one. resized_tensor = K.resize(image_tensor, (128, 128), interpolation="bilinear") print(f"Resized image tensor shape: {resized_tensor.shape}") # Convert resized tensor back to NumPy for further processing or visualization np_resized_image = np.from_dlpack(resized_tensor) print(f"Resized NumPy array shape: {np_resized_image.shape}, dtype: {np_resized_image.dtype}") # Clean up dummy image if created if os.path.exists('dummy.jpeg') and 'Created' in locals(): os.remove('dummy.jpeg') print("Removed 'dummy.jpeg'.")
Debug
Known issues
breakingAs a library in active development and in early versions (0.1.x), expect potential breaking changes between minor versions. API signatures, especially for core functionalities like `warp_affine` or tensor allocators, have undergone refactoring in past releases.
fix
Always consult the latest GitHub README and release notes when upgrading, and adapt your code to new API signatures. Pin your minor version to ensure stability within a project (e.g., `kornia-rs==0.1.*`).
affects: <=0.1.10
gotchaCertain features, such as optimized JPEG decoding (via `turbojpeg`) or video processing (via `gstreamer`), may require additional system-level dependencies (e.g., `nasm`, `libgstreamer1.0-dev`). These are not automatically installed with `pip install kornia-rs`.
fix
Check the `kornia-rs` GitHub documentation for a full list of optional system dependencies relevant to the features you intend to use and install them manually if needed.
affects: All
gotchaKornia-rs is a Rust-first library with Python bindings. Only a subset of the full Rust API is exposed to Python. Not all functionalities available in the Rust crate are directly accessible from Python.
fix
Refer to the `kornia` (PyTorch) documentation or `kornia-rs` specific documentation for the exact Python-exposed functions and objects. Avoid assuming direct parity with the Rust API.
affects: All
gotchaThe `kornia_rs.Tensor` objects use DLPack for zero-copy data transfer to NumPy and PyTorch tensors. While highly efficient, this means direct modifications to the underlying `kornia_rs.Tensor` after conversion might affect the derived NumPy/PyTorch tensors, and vice versa.
fix
Be mindful of shared memory when performing operations on tensors converted via DLPack. If independent copies are needed, explicitly clone the tensor after conversion (e.g., `np_array = np.from_dlpack(image_tensor).copy()`).
affects: All
Errors
Common errors & fixes
error: metadata-generation-failed × Encountered error while generating package metadata.
This error occurs when `pip` attempts to build the `kornia-rs` Python package from source (e.g., because a pre-built wheel is unavailable for your specific system/Python version/architecture) and the underlying Rust build process, managed by `maturin` and `cargo`, fails due to missing Rust toolchain components, incompatible Rust versions, or environment issues.
fix
Ensure you have a working Rust toolchain installed (e.g., by running `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`). Also, make sure `pip` and `setuptools` are up-to-date (`pip install --upgrade pip setuptools`). If building from source is necessary, confirm your system has the required build tools for Rust and Python bindings.
ModuleNotFoundError: No module named 'kornia_rs'
The `kornia-rs` Python package was not successfully installed, or the Python interpreter cannot find it in the current environment's `PYTHONPATH`.
fix
Install `kornia-rs` using pip (`pip install kornia-rs`). If already installed, ensure your Python virtual environment is correctly activated and that `kornia_rs` is installed for the specific Python interpreter you are using. Verify installation with `pip show kornia-rs`.
OSError: cannot open shared object file: libturbojpeg.so: No such file or directory
`kornia-rs` relies on optional system-level libraries, such as `libturbojpeg` for fast JPEG I/O, which are not installed on your system or are not discoverable by the dynamic linker. This error can also occur for other optional dependencies like GStreamer.
fix
Install the missing system dependency using your operating system's package manager. For `libturbojpeg` on Debian/Ubuntu-based systems, run `sudo apt-get install libturbojpeg0`. For `nasm` (a common dependency for `turbojpeg`), run `sudo apt-get install nasm`. For GStreamer support, install development packages like `sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev`.
Upgrade
Version history
0.1.14latest on PyPI · released May 19, 2026
Audit
Dependencies
numpyoptionalUsed for zero-copy conversion of kornia-rs Tensors to NumPy arrays via DLPack.
torchoptionalUsed for zero-copy conversion of kornia-rs Tensors to PyTorch Tensors via DLPack.
Agent activity
9 hits · last 30 days
node
6
Resources
kornia-rs — pip install kornia-rs · libregistry