ONNX is an open format to represent deep learning models. With ONNX, AI developers can more easily move models between state-of-the-art tools and choose the combination that is best for them. ONNX is developed and supported by a community of partners.
Converting models to ONNX makes it easy to use them in a wide variety of optimized applications. Visual Studio Tools for AI will generate code from ONNX models and TensorFlow models to make it easy to include models in your applications. However, only ONNX models are supported by Windows Machine Learning (ML).
Visual Studio Tools for AI makes it easy to convert trained models to ONNX by leveraging existing model converters. You can learn more about the model converter utilities here, or simply use the wizard in Visual Studio to create your ONNX model.
Currently, Visual Studio Tools for AI supports converting machine learning and deep learning framework models to ONNX from the following frameworks:
- Core ML
- TensorFlow
- Scikit-Learn
- XGBoost
- LIBSVM
To install prerequisites for converting XGBoost and LibSVM models
Then run the following from your command line:
pip3 install tensorflow==1.5.0 scikit-learn onnx "git+https://github.com/apple/coremltools@v0.8" onnxmltools winmltools "git+https://github.com/onnx/tensorflow-onnx.git@r0.1"
- Choose AI Tools > Model Tools > Convert Model... on the menu bar.
- Select source model type and file.
- Select target model type(we only support ONNX currently) and file.
You can convert two types of TensorFlow models to ONNX:
-
Frozen protobuf model (file extension is *.pb)
-
Checkpoint MetaGraphDef model (file extension is *.meta )
-
Add input nodes and output nodes. The node name must in the graph.
- Input graph name for the ONNX model.
- Add input features according to the input of the source model.
- After clicking the OK button, Visual Studio Tools for AI will first check whether dependent software is installed.
- If yes, a converter task will be added to task list explorer.
- When the converter task succeeds, File Explorer is opened with the target model file selected.