Exporting YOLO models to ONNX with embedded pre and post processing
This repository contains the code to export Yolo models to ONNX format using the runtime extensions to add pre and post processing to the exported ONNX.
Models supported (code examples on how to use in examples folder):
- YOLOv8 Classification.
- YOLOv8 Object Detection
- YOLOv8 Segmentation.
- Processing of resulting box coordinates only covered. Segmentation polygon not supported yet
Python Installation
YOLO2ONNX Extended package
Create a python environment and install using the wheel package file:
pip install yolo2onnx_extended-0.0.1-py3-none-any.whl
Build from raw
Clone this repo and install the main requirements:
- PyTorch:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 - Ultralyics:
pip install ultralytics - ONNX Runtime:
- CPU:
pip install onnxruntime - GPU (CUDA 11.8):
pip install onnxruntime-gpu
- CPU:
- ONNX Runtime Extensions:
pip install onnxruntime-extensions
Use of exported model in other platforms (C/C#/C++/JavaScript/Android/iOS)
ONNX packages need to be installed. Check the supported versions for the platform you are using.
- ONNX Runtime installations for other platforms can be found in the documentation.
- ONNX Extensions installations can be found in the documentation.
[Inference install table for all languagues](Be aware of the supported versions of the extensions.)
Useful resources and Ideas
- API - Python API documentation (onnxruntime.ai)
- CUDA Optimization: NVIDIA - CUDA | onnxruntime
- Model Quantization with ONNX
- ONNX Model Visualizer: Netron
- Processing Segmentation YOLOV8 ONNX
- Python Packaging
Inference Benchmarks
- CPU (Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz 6 cores, 12 virtual):
- Object Detection
0.35 secsper image
- Object Detection
- GPU (NVIDIA Quadro T2000 with Max-Q Design):
- Object Detection:
4 - 5 secsfor first image.0.068for rest of images
- Object Detection:
Metadata
Release files for yolo2onnx-extended 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yolo2onnx_extended-0.2.2.tar.gz | 11.2 kB | Without provenance | Details for yolo2onnx_extended-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yolo2onnx_extended-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for yolo2onnx_extended-0.2.2-py3-none-any.whl |
Total release size: 22.2 kB
Release files / yolo2onnx_extended-0.2.2.tar.gz
| Download URL | yolo2onnx_extended-0.2.2.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c3d83fd1fe370065229b576fe763fbf71c9fab58b68054448bacfbef50e87f2
|
|
BLAKE2b-256 checksum How to use checksums |
e55645fc0b32be4d02bee7dd541f12872199a979df96e31d524a4b796de6be27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Release files / yolo2onnx_extended-0.2.2-py3-none-any.whl
| Download URL | yolo2onnx_extended-0.2.2-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
283636990dd16f2f597c95f5933276e330c8df12f7f49fcae9bd56e1f2cb46dd
|
|
BLAKE2b-256 checksum How to use checksums |
23e348eb432e1ef9e044689b593480ed1bc3c15dedd01fe77b68224be9d1fe9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Security for yolo2onnx-extended 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.