Converting Trained Models to Core ML

Overview

If your model is created and trained using a supported third-party machine learning framework, you can use the Core ML Tools or a third-party conversion tool—such as the MXNet converter or the TensorFlow converter—to convert your model to the Core ML model format. Otherwise, you need to create your own conversion tools.

Use Core ML Tools

Core ML Tools is a Python package that converts a variety of model types into the Core ML model format. Table 1 lists the supported models and third-party frameworks.

Depending on your model, you might need to update inputs, outputs, and labels, or you might need to declare image names, types, and formats. The conversion tools are bundled with more documentation, as the options available vary by tool. For more information about Core ML Tools, see the Package Documentation.

Alternatively, Write a Custom Conversion Tool

It's possible to create your own conversion tool when you need to convert a model that isn't in a format supported by the tools listed above.

Writing your own conversion tool involves translating the representation of your model's input, output, and architecture into the Core ML model format. You do this by defining each layer of the model's architecture and its connectivity with other layers. Use the conversion tools provided by Core ML Tools as examples; they demonstrate how various model types created from third-party frameworks are converted to the Core ML model format.