Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 2.92 KB

model-converter.md

File metadata and controls

57 lines (41 loc) · 2.92 KB

Converting models to ONNX

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

Prerequisites

To install prerequisites for converting XGBoost and LibSVM models

  • Install XGBoost 64-bit Windows package
  • Install LIBSVM 64-bit Windows package

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"

Launch Model Converter

  • 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.

Convert Core ML model

  • Input graph name for ONNX model.

    Convert CoreML

Convert TensorFlow model

You can convert two types of TensorFlow models to ONNX:

  • Frozen protobuf model (file extension is *.pb)

  • Checkpoint MetaGraphDef model (file extension is *.meta )

    Open folder

  • Add input nodes and output nodes. The node name must in the graph.

Convert TensorFlow

Convert Scikit-Learn/XGBoost/LIBSVM model

  • Input graph name for the ONNX model.
  • Add input features according to the input of the source model.

Convert Sckikit

Start Converting

  • 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.

Convert Tasklist