Sample code of converting CoreML MobileNet into Windows Machine Learning. We prepare CoreML MobileNet for image classification from here.
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.
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.