Implementation:Kornia Kornia ONNXLoader Load Model
Appearance
| Knowledge Sources | |
|---|---|
| Domains | ONNX, Deployment |
| Last Updated | 2026-02-09 15:00 GMT |
Overview
Concrete tool for loading ONNX models from various sources provided by Kornia's ONNX utility module.
Description
ONNXLoader.load_model is a static method that loads ONNX model files from local paths, URLs, or HuggingFace Hub. It uses CachedDownloader for network sources, supports loading external weight data, and returns onnx.ModelProto objects. HuggingFace Hub models use the "hf://operators/model_name" URI format.
Usage
Import and call as a static method before constructing ONNXSequential pipelines.
Code Reference
| Repository | https://github.com/kornia/kornia |
|---|---|
| File | kornia/onnx/utils.py
|
| Lines | L37–130 |
| Signature | class ONNXLoader: @staticmethod def load_model(model_name: str, download: bool = True, with_data: bool = False, **kwargs) -> onnx.ModelProto
|
| Import | from kornia.onnx import ONNXLoader
|
I/O Contract
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
model_name |
str |
Yes | Model identifier — local path, URL, or "hf://operators/name"
|
download |
bool |
No | Download if not cached (default True)
|
with_data |
bool |
No | Load external weight data (default False)
|
Outputs
onnx.ModelProto — the loaded model object.
Usage Examples
Load from HuggingFace Hub
from kornia.onnx import ONNXLoader
model = ONNXLoader.load_model("hf://operators/resize")
print(type(model)) # <class 'onnx.onnx_ml_pb2.ModelProto'>
Load from local path
from kornia.onnx import ONNXLoader
model = ONNXLoader.load_model("/path/to/model.onnx")
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment