Migrating to This Version

The coremltools 4.1 package provides many improvements over coremltools 3.4, especially in the area of neural network model conversion. This page also describes deprecated methods and Python version support.

Neural network model conversion

If you used coremltools 3 for neural network model conversion from TensorFlow or ONNX/PyTorch to Core ML, update your workflow for migrating to coremltools 4 as follows:

Conversion fromcoremltools 3coremltools 4
TensorFlowInstall coremltools 3.4 and tfcoreml 1.1 and use the tfcoreml.convert API.Use the new coremltools.convert API. See Unified Conversion API.
PyTorchFirst export the PyTorch model to the ONNX format and then install coremltools 3.4 and onnx-coreml 1.3 and use the onnx_coreml.convert API.Use the new coremltools.convert API. See Unified Conversion API.

Convert from TensorFlow

With coremltools 4 you do not need to install the tfcoreml package to convert TensorFlow models. The TensorFlow converter is now fully integrated in coremltools and available in the Unified Conversion API.

🚧

For older deployment targets

To deploy the Core ML model to a target that is iOS12, macOS 10.13, watchOS 5, tvOS 12, or an older version, use coremltools 3 and tfcoreml 1.

Convert from PyTorch

You can directly convert from PyTorch using coremltools 4, which includes a PyTorch converter available through the Unified Conversion API. You no longer need to use the two-step process for converting PyTorch models using the ONNX format.

🚧

For older deployment targets

To deploy the Core ML model to a target that is iOS12, macOS 10.13, watchOS 5, tvOS 12, or an older version, use coremltools 3 and onnx-coreml 1.

Deprecated methods and Python version support

The coremltools 4.1 package has deprecated support for Python 2. The package includes wheels for Python 3.5, 3.6, 3.7, and 3.8.

🚧

Warning

The next major release of coremltools will deprecate convert_neural_network_weights_to_fp16() and convert_neural_network_spec_weights_to_fp16(). Use the quantize_weights() method instead. For instructions, see Quantization.

The coremltools 4.0 package has deprecated the following class and methods that were available in the previous version (coremltools 3.4):

  • The NeuralNetworkShaper class.
  • get_allowed_shape_ranges().
  • can_allow_multiple_input_shapes().
  • visualize_spec() method of the MLModel class. You can use the netron open source viewer to visualize CoreML models.
  • quantize_spec_weights(). Use the quantize_weights() method instead. For instructions, see Quantization.
  • get_custom_layer_names(), replace_custom_layer_name(), and has_custom_layer(): These were moved to internal methods.

Reporting issues

To report issues, see Contributing. To submit a pull request, see the list of current pull requests.