c#, Windows ML, XAML
Sample application for ONNX1.2 models exported from Custom Vision Service
This sample application demonstrates how to take a model exported from the Custom Vision Service in the ONNX format and add it to an application for real-time image classification.
- Windows SDK - Build 17738+ (latest)
- Visual Studio 17
- Windows 10 Insider Preview 17738+
- An account at Custom Vision Service
- Clone the repository and open the project in Visual Studio
- Build and run the sample Application
- Application comes with two models already included along with sample images to test.
Adding your own sample model of your own classifier
The models provided with the sample recognizes Hemlock/Japanese Cherry images. To add your own model exported from the Custom Vision Service do the following, and then build and launch the application:
- Create and train a classifer with the Custom Vision Service. You must choose a "compact" domain such as General (compact) to be able to export your classifier. If you have an existing classifier you want to export instead, convert the domain in "settings" by clicking on the gear icon at the top right. In setting, choose a "compact" model, Save, and Train your project.
- Export your model by going to the Performance tab. Select an iteration trained with a compact domain, an "Export" button will appear. Click on Export then ONNX then ONNX1.2 then Export. Click the Download button when it appears. A *.onnx file will download.
- Drop your *model.onnx file into your project's Assets folder.
- Under Solutions Explorer/ Assets Folder add model file to project by selecting Add Existing Item.
- Change properties of model just added: "Build Action" -> "Content" and "Copy to Output Directory" -> "Copy if newer"
- Add to list variable "onnxFileNames" name of model just added along with number of lables model contains.
- Build and run.
- Click button to select image to evaluate.
Things to note
- The test image should larger than 227 x 227
- Link to ONNX
- Link to ONNX on GitHub
- Link to Get started with Windows Machine Learning
- Link to More Information about ONNX version and Windows Machine Learning
- Link to Custom Vision Service Documentation