ONNX Runtime examples for Unity
Examples of ONNX Runtime Unity Plugin.
2023-12-25-onnx-yolox.mp4
Tested environment
- Unity: 2022.3.16f1 (LTS)
- ONNX Runtime: 1.16.3
- macOS, iOS, Android, Windows, Linux.
- Complete List for 🔗 Supported Execution Providers
How to Run
Try all examples
Pull this repository with Git-LFS
Install pre-built ONNX Runtime via Unity Package Manager (UPM)
Add the following scopedRegistries
and dependencies
in Packages/manifest.json
.
"scopedRegistries": [
{
"name": "NPM",
"url": "https://registry.npmjs.com",
"scopes": [
"com.github.asus4"
]
}
]
"dependencies": {
// Core library
"com.github.asus4.onnxruntime": "0.1.5",
// (Optional) Utilities for Unity
"com.github.asus4.onnxruntime.unity": "0.1.5",
... other dependencies
}
How to convert Onnx to Ort format
On the mobile platform, the *.onnx model is not recommended, although it's supported on the desktop. Convert the Onnx model to Ort format.
Please refer to the ORT model format for more details.
TL;DR;
# Recommend using python virtual environment
pip install onnx
pip install onnxruntime
# In general,
# Use --optimization_style Runtime, when running on mobile GPU
# Use --optimization_style Fixed, when running on mobile CPU
python -m onnxruntime.tools.convert_onnx_models_to_ort your_onnx_file.onnx --optimization_style Runtime
Acknowledgements
- PINTO_model_zoo: Some ORT models are converted from this repository.