Use an ONNX model from Custom Vision with Windows ML (preview)

Learn how to use an ONNX model exported from the Custom Vision service with Windows ML (preview). You'll use an example UWP application with your own trained image classifier.


  • Windows 10 version 1809 or higher
  • Windows SDK for build 17763 or higher
  • Visual Studio 2017 version 15.7 or later with the Universal Windows Platform development workload enabled.
  • Developer mode enabled on your PC. For more information, see Enable your device for development.

About the example app

The included application is a generic Windows UWP app. It allows you to select an image from your computer and process it using a locally stored classification model. The tags and scores returned by the model are displayed next to the image.

Get the application

The example application is available at the Azure AI services ONNX Custom Vision Sample repo on GitHub. Clone it to your local machine and open SampleOnnxEvaluationApp.sln in Visual Studio.

Test the application

  1. Use the F5 key to start the application from Visual Studio. You may be prompted to enable Developer mode.
  2. When the application starts, use the button to select an image for scoring. The default ONNX model is trained to classify different types of plankton.

Use your own model

To use your own image classifier model, follow these steps:

  1. Create and train a classifier with the Custom Vision Service. For instructions on how to do this, see Create and train a classifier. Use one of the compact domains such as General (compact).
    • If you have an existing classifier that uses a different domain, you can convert it to compact in the project settings. Then, re-train your project before continuing.
  2. Export your model. Switch to the Performance tab and select an iteration that was trained with a compact domain. Select the Export button that appears. Then select ONNX, and then Export. Once the file is ready, select the Download button. For more information on export options, see Export your model.
  3. Open the downloaded .zip file and extract the model.onnx file from it. This file contains your classifier model.
  4. In the Solution Explorer in Visual Studio, right-click the Assets Folder and select Add Existing Item. Select your ONNX file.
  5. In Solution Explorer, right-click the ONNX file and select Properties. Change the following properties for the file:
    • Build Action -> Content
    • Copy to Output Directory -> Copy if newer
  6. Then open MainPage.xaml.cs and change the value of _ourOnnxFileName to the name of your ONNX file.
  7. Use the F5 to build and run the project.
  8. Select button to select image to evaluate.

Next steps

To discover other ways to export and use a Custom Vision model, see the following documents:

For more information on using ONNX models with Windows ML, see Integrate a model into your app with Windows ML.