Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.44 KB

README.md

File metadata and controls

42 lines (30 loc) · 1.44 KB

WindowsML-CoreML-MobileNet-demo

Sample code of converting CoreML MobileNet into Windows Machine Learning.
We prepare CoreML MobileNet for image classification from here.

mobilenet_demo

Prepare model

Download MobileNet model from Core ML Store.
Then you see MobileNet.mlmodel , move model file to ./convert_model directory.

We use coremltools for loading CoreML model and winmltools for converting CoreML model into ONNX format.
First, install coremltools and winmltools by pip.

pip install coremltools winmltools

Second, execute python file for converting CoreML model.

python coreml2onnx.py

After execution, you will get two files mobilenet.onnx and mobilenet.txt.
Third, create C# code describing ONNX model.

"C:\Program Files (x86)\Windows Kits\10\bin\10.0.17125.0\x64\mlgen.exe" -i mobilenet.onnx -l CS -n mobilenet -o mobilenet.cs

mobilenet.cs describes three classes MobilenetModelInput and MobilenetModelOutputand MobilenetModel.
Each class correspond Network input(image), Network output(class label and probability) and MobileNet Network and inference method.

Finally, move each files.
mobilenet.cs -> {solution dir}
mobilenet.onnx -> {solution dir}/Assets

Run demo

Start solution application.

Deploying the sample

  • Select Build > Deploy Solution.