ONNX tutorials
Open Neural Network Exchange (ONNX) is an open standard format for representing machine learning models offering interoperability between various AI frameworks. With ONNX, AI developers can choose the best framework for training and switch to a different one for shipping.
ONNX is supported by a community of partners, and more and more AI frameworks are building ONNX support including PyTorch, Caffe2, Microsoft Cognitive Toolkit and Apache MXNet.
- Choose a pre-trained ONNX model from the ONNX Model Zoo. A lot of pre-trained ONNX models are provided for common scenarios.
- Convert models from mainstream frameworks. More tutorials are below.
Framework / tool | Installation | Exporting to ONNX (frontend) | Importing ONNX models (backend) |
---|---|---|---|
Caffe | apple/coremltools and onnx/onnxmltools | Exporting | n/a |
Caffe2 | part of caffe2 package | Exporting | Importing |
Chainer | chainer/onnx-chainer | Exporting | coming soon |
Cognitive Toolkit (CNTK) | built-in | Exporting | Importing |
Apple CoreML | onnx/onnx-coreml and onnx/onnxmltools | Exporting | Importing |
Keras | onnx/kera-onnx | Exporting | n/a |
LibSVM | onnx/onnxmltools | Exporting | n/a |
LightGBM | onnx/onnxmltools | Exporting | n/a |
MATLAB | onnx converter on matlab central file exchange | Exporting | Importing |
Menoh | pfnet-research/menoh | n/a | Importing |
ML.NET | built-in | Exporting | Importing |
Apache MXNet | part of mxnet package docs github | Exporting | Importing |
PyTorch | part of pytorch package | Exporting, Extending support | coming soon |
SciKit-Learn | onnx/sklearn-onnx | Exporting | n/a |
TensorFlow | onnx/onnx-tensorflow and onnx/tensorflow-onnx | Exporting | Importing [experimental] |
TensorRT | onnx/onnx-tensorrt | n/a | Importing |
- Use services like Azure Custom Vision service that generate customized ONNX models for your data
-
For preparation
-
For serving
- Serving ONNX models with MXNet Model Server
- ONNX model hosting with AWS SageMaker and MXNet
- Serving ONNX models with ONNX Runtime on Azure ML - FER Facial Expression Recognition, MNIST Handwritten Digits, Resnet50 Image Classification
- Inferencing ONNX models using ONNX Runtime Python API
- Train a Scikit-learn pipeline, convert to ONNX, and score with ONNX Runtime
-
For conversion
-
From conversion to deployment
- Converting SuperResolution model from PyTorch to Caffe2 with ONNX and deploying on mobile device
- Transferring SqueezeNet from PyTorch to Caffe2 with ONNX and to Android app
- Converting Style Transfer model from PyTorch to CoreML with ONNX and deploying to an iPhone
- Serving PyTorch Models on AWS Lambda with Caffe2 & ONNX
- MXNet to ONNX to ML.NET with SageMaker, ECS and ECR - external link
- Convert CoreML YOLO model to ONNX, score with ONNX Runtime, and deploy in Azure
- Verifying correctness and comparing performance
- Visualizing an ONNX model (useful for debugging)
- Netron: a viewer for ONNX models
- Example of operating on ONNX protobuf
- Float16 <-> Float32 converter
We welcome improvements to the convertor tools and contributions of new ONNX bindings. Check out contributor guide to get started.
Use ONNX for something cool? Send the tutorial to this repo by submitting a PR.