You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: "Tutorial: Use an ONNX model with Windows ML - Custom Vision Service"
2
+
title: "Use an ONNX model with Windows ML - Custom Vision Service"
3
3
titleSuffix: Azure Cognitive Services
4
4
description: Learn how to create a Windows UWP app that uses an ONNX model exported from Azure Cognitive Services.
5
5
services: cognitive-services
@@ -8,69 +8,52 @@ manager: nitinme
8
8
9
9
ms.service: cognitive-services
10
10
ms.subservice: custom-vision
11
-
ms.topic: tutorial
12
-
ms.date: 04/14/2020
11
+
ms.topic: conceptual
12
+
ms.date: 04/29/2020
13
13
ms.author: pafarley
14
14
# As a developer, I want to use a custom vision model with Windows ML.
15
15
---
16
16
17
-
# Tutorial: Use an ONNX model from Custom Vision with Windows ML (preview)
17
+
# Use an ONNX model from Custom Vision with Windows ML (preview)
18
18
19
19
Learn how to use an ONNX model exported from the Custom Vision service with Windows ML (preview).
20
20
21
-
The information in this document demonstrates how to use an ONNX file exported from the Custom Vision Service with Windows ML. An example Windows UWP application is provided. A trained model that can recognize is included with the example. Steps are also provided on how you can use your own model with this example.
22
-
23
-
> [!div class="checklist"]
24
-
> * About the example app
25
-
> * Get the example code
26
-
> * Run the example
27
-
> * Use your own model
21
+
In this guide, you'll learn how to use an ONNX file exported from the Custom Vision Service with Windows ML. You'll use the example UWP application with your own trained image classifier.
28
22
29
23
## Prerequisites
30
24
31
25
* Windows 10 version 1809 or higher
32
-
33
26
* Windows SDK for build 17763 or higher
34
-
35
27
* Visual Studio 2017 version 15.7 or later with the __Universal Windows Platform development__ workload enabled.
36
-
37
-
* Developer mode enabled. For more information, see the [Enable your device for development](https://docs.microsoft.com/windows/uwp/get-started/enable-your-device-for-development) document.
28
+
* Developer mode enabled on your PC. For more information, see [Enable your device for development](https://docs.microsoft.com/windows/uwp/get-started/enable-your-device-for-development).
38
29
39
30
## About the example app
40
31
41
-
The application is a generic Windows UWP application. It allows you to select an image from your computer, which is then sent to the model. The tags and scores returned by the model are displayed next to the image.
32
+
The included application is a generic Windows UWP app. It allows you to select an image from your computer, which is then processed by a locally stored classification model. The tags and scores returned by the model are displayed next to the image.
42
33
43
34
## Get the example code
44
35
45
-
The example application is available at [https://github.com/Azure-Samples/cognitive-services-onnx-customvision-sample](https://github.com/Azure-Samples/cognitive-services-onnx-customvision-sample).
36
+
The example application is available at the [Cognitive Services ONNX Custom Vision Sample](https://github.com/Azure-Samples/cognitive-services-onnx-customvision-sample) repo on GithHub. Clone it to your local machine and open *SampleOnnxEvaluationApp.sln* in Visual Studio.
46
37
47
-
## Run the example
38
+
## Test the application
48
39
49
-
1. Use the `F5` key to start the application from Visual Studio. You may be prompted to enable Developer mode. For more information, see the [Enable your device for development](https://docs.microsoft.com/windows/uwp/get-started/enable-your-device-for-development) document.
50
-
51
-
1. When the application starts, use the button to select an image for scoring.
40
+
1. Use the `F5` key to start the application from Visual Studio. You may be prompted to enable Developer mode.
41
+
1. 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.
52
42
53
43
## Use your own model
54
44
55
-
To use your own model, use the following steps:
56
-
57
-
1.[Create and train](https://docs.microsoft.com/azure/cognitive-services/custom-vision-service/getting-started-build-a-classifier) a classifier with the Custom Vision Service. To export the model, select a __compact__ domain such as **General (compact)**. To export an existing classifier, convert the domain to compact by selecting the gear icon at the top right. In __Settings__, choose a compact model, save, and train your project.
58
-
59
-
1.[Export your model](https://docs.microsoft.com/azure/cognitive-services/custom-vision-service/export-your-model) by going to the Performance tab. Select an iteration trained with a compact domain, an "Export" button will appear. Select *Export*, *ONNX*, and then *Export*. Once the file is ready, select the *Download* button.
60
-
61
-
1. Drop the ONNX file into your project's __Assets__ folder.
62
-
63
-
1. In Solutions Explorer, right-click the Assets Folder and select __Add Existing Item__. Select the ONNX file.
64
-
65
-
1. In Solutions Explorer, select the ONNX file from the Assets folder. Change the following properties for the file:
66
-
67
-
*__Build Action__ -> __Content__
68
-
*__Copy to Output Directory__ -> __Copy if newer__
69
-
70
-
1. Change the `_onnxFileNames` variable to the name of the ONNX file. Also modify `ClassLabel` to the number of labels the model contains.
71
-
72
-
1. Build and run.
73
-
45
+
To use your own image classifier model, follow these steps:
46
+
47
+
1. Create and train a classifier with the Custom Vision Service. For instructions on how to do this, see [Create and train a classifier](https://docs.microsoft.com/azure/cognitive-services/custom-vision-service/getting-started-build-a-classifier). Use one of the **compact** domains such as **General (compact)**.
48
+
* 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.
49
+
1. 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](https://docs.microsoft.com/azure/cognitive-services/custom-vision-service/export-your-model).
50
+
1. Open the downloaded *.zip* file and extract the *model.onnx* file from it. This file contains your classifier model.
51
+
1. In the Solution Explorer in Visual Studio, right-click the **Assets** Folder and select __Add Existing Item__. Select your ONNX file.
52
+
1. In Solution Explorer, right-click the ONNX file and select **Properties**. Change the following properties for the file:
53
+
*__Build Action__ -> __Content__
54
+
*__Copy to Output Directory__ -> __Copy if newer__
55
+
1. Then open _MainPage.xaml.cs_ and change the value of `_ourOnnxFileName` to the name of your ONNX file.
56
+
1. Use the `F5` to build and run the project.
74
57
1. Click button to select image to evaluate.
75
58
76
59
## Next steps
@@ -82,4 +65,4 @@ To discover other ways to export and use a Custom Vision model, see the followin
82
65
*[Use exported CoreML model in a Swift iOS application](https://go.microsoft.com/fwlink/?linkid=857726)
83
66
*[Use exported CoreML model in an iOS application with Xamarin](https://github.com/xamarin/ios-samples/tree/master/ios11/CoreMLAzureModel)
84
67
85
-
For more information on using ONNX models with Windows ML, see the [Integrate a model into your app with Windows ML](/windows/ai/windows-ml/integrate-model) document.
68
+
For more information on using ONNX models with Windows ML, see [Integrate a model into your app with Windows ML](/windows/ai/windows-ml/integrate-model).
0 commit comments