Skip to content

Commit bbbbba4

Browse files
committed
fix onnx guide
1 parent 374fa6c commit bbbbba4

File tree

1 file changed

+24
-41
lines changed

1 file changed

+24
-41
lines changed
Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Tutorial: Use an ONNX model with Windows ML - Custom Vision Service"
2+
title: "Use an ONNX model with Windows ML - Custom Vision Service"
33
titleSuffix: Azure Cognitive Services
44
description: Learn how to create a Windows UWP app that uses an ONNX model exported from Azure Cognitive Services.
55
services: cognitive-services
@@ -8,69 +8,52 @@ manager: nitinme
88

99
ms.service: cognitive-services
1010
ms.subservice: custom-vision
11-
ms.topic: tutorial
12-
ms.date: 04/14/2020
11+
ms.topic: conceptual
12+
ms.date: 04/29/2020
1313
ms.author: pafarley
1414
# As a developer, I want to use a custom vision model with Windows ML.
1515
---
1616

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)
1818

1919
Learn how to use an ONNX model exported from the Custom Vision service with Windows ML (preview).
2020

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

2923
## Prerequisites
3024

3125
* Windows 10 version 1809 or higher
32-
3326
* Windows SDK for build 17763 or higher
34-
3527
* 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).
3829

3930
## About the example app
4031

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

4334
## Get the example code
4435

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

47-
## Run the example
38+
## Test the application
4839

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

5343
## Use your own model
5444

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.
7457
1. Click button to select image to evaluate.
7558

7659
## Next steps
@@ -82,4 +65,4 @@ To discover other ways to export and use a Custom Vision model, see the followin
8265
* [Use exported CoreML model in a Swift iOS application](https://go.microsoft.com/fwlink/?linkid=857726)
8366
* [Use exported CoreML model in an iOS application with Xamarin](https://github.com/xamarin/ios-samples/tree/master/ios11/CoreMLAzureModel)
8467

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

Comments
 (0)