File size: 2,658 Bytes
9e7b99f
 
 
 
 
 
 
 
45eabf5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0033d20
 
45eabf5
 
 
 
 
 
 
 
 
 
 
 
 
a0e5c83
 
b00a6f9
0033d20
a0e5c83
45eabf5
a0e5c83
45eabf5
 
 
 
0a9eb59
 
 
45eabf5
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
language:
- en
tags:
- kornia
- onnx
---

# Kornia ONNX Repository

Welcome to the **Kornia ONNX Repository**! This repository hosts ONNX files for models and operators related to the Kornia computer vision library. Here, you'll find pre-trained models, custom operators, and resources to accelerate your machine learning and computer vision workflows using ONNX format.

![Kornia ONNX](./banner.jpeg)


## Repository Structure

By default, we include ONNX models with dynamic shapes. If the model is exported with a specific input shape, it would be noted in the filename such as `XXX_512x512.onnx`.

The repository is organized into two main folders:

### 1. **Operators**
   This folder contains various ONNX operators used within the Kornia library. These operators are designed to be modular and can be integrated into different models or workflows. Each operator comes with a brief description and example usage.

### 2. **Models**
   This folder contains complete models built with Kornia and exported to ONNX format. These models are designed for various computer vision tasks such as image processing, stereo vision, and more. Each model is accompanied by a detailed description of its purpose and how to use it.
   > [!Note]
   > The detection models exported in this repo do not include a postprocessor, you may need to do it yourself or re-export the model by setting `confidence_filtering=True`. For example, `RTDETRDetectorBuilder.to_onnx(confidence_threshold=0.5, confidence_filtering=True)`.

## Getting Started

Install Kornia library:
```shell
pip install -U kornia
```

To chain many operators or models into one graph, follow these steps:

```python
import numpy as np
from kornia.onnx import ONNXSequential
# Chain ONNX models from HuggingFace repo and your own local model together
onnx_seq = ONNXSequential(
    "hf://operators/kornia.geometry.transform.flips.Hflip",
    "hf://models/kornia.models.detection.rtdetr_r18vd_640x640",  # Or you may use "YOUR_OWN_MODEL.onnx"
)
# Prepare some input data
input_data = np.random.randn(1, 3, 384, 512).astype(np.float32)
# Perform inference
outputs = onnx_seq(input_data)
# Print the model outputs
print(outputs)

# Export a new ONNX model that chains up all three models together!
onnx_seq.export("chained_model.onnx")
```

## Contribution

We welcome contributions! If you'd like to add your own ONNX operators or models, feel free to open a pull request. Please ensure that you include relevant documentation and example usage for any new additions.

Thank you for using the Kornia ONNX Repository! Feel free to explore and contribute to the growing collection of operators and models.