Skip to content
A Xamarin.Forms app showcasing how to use Custom Vision Service with either online and offline models.
Branch: master
Clone or download
marcominerva Merge pull request #17 from DotNetToscana/dev
Update UWP version to ONNX 1.2 and SDK 17763
Latest commit d5ef897 Jan 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Screenshots Add files via upload Jul 16, 2018
Src Delete unused field Jan 27, 2019
.gitignore iOS Version Apr 6, 2018
LICENSE Initial commit Jan 17, 2018
README.md Update README.md Jan 27, 2019

README.md

Custom Vision Companion

A Xamarin.Forms app showcasing how to use Custom Vision Service with either online and offline models. Android, iOS and UWP are currently supported.

A screenshot of the Android version

A screenshot of the UWP version

Getting started

To use an online model, launch the app, go to the Settings page and then set Prediction Key and Project Id from Custom Vision Service Project Settings.

The sample contains an offline model exported from Custom Vision Service, for Android, iOS and UWP. It has been trained to recognize laptops, keyboards, mice, monitors and controllers. You can easily replace it with your own: after the training, you just need to download the models from Custom Vision Service Portal.

Android offline models

  • Replace the model.pb and labels.txt files in the Assets folder with your own model. Be sure that the Build Action of both files must be set to AndroidAsset.

  • Add the following line in the OnCreate method in MainActivity.cs:

CrossOfflineClassifier.Current.InitializeAsync(ModelType.General, "model.pb", "labels.txt");

iOS offline models

  • Replace the .mlmodel file in the Resources folder with your own model. Be sure that the Build Action of this file must be set to BundleResource. The model will be automatically compiled at app startup.
  • OR
  1. Manually compile the ML model and add it to the project. The CoreML compiler is included with the Xcode developer tools (Xcode 9 and higher). To compile an .mlmodel, run:
xcrun coremlcompiler compile {model.mlmodel} {outputFolder}
  1. Put the output folder inside the Resources folder. Be sure that the Build Action of each file must be set to BundleResource.
CrossOfflineClassifier.Current.InitializeAsync(ModelType.General, "Computer");

UWP offline models

  • Replace the Computer.onnx file in the Assets/Models folder with your own model. Be sure that the Build Action of this file must be set to Content. Note that, when you add the file to the project, Visual Studio will automatically create a .cs file containing the code to use the model. You can safely delete it, as this project already contains a standard implementation.

  • Add the following line in the constructor of MainPage.xaml.cs:

CrossOfflineClassifier.Current.InitializeAsync(ModelType.General, "ms-appx:///Assets/Models/Computer.onnx");

Contribute

The project is continuously evolving. We welcome contributions. Feel free to file issues and pull requests on the repo and we'll address them as we can.

You can’t perform that action at this time.