Integrate machine learning models into your app. 将机器学习模型集成到您的应用程序中。
With Core ML, you can integrate trained machine learning models into your app. 使用Core ML，您可以将受过训练的机器学习模型集成到您的应用程序中。
A trained model is the result of applying a machine learning algorithm to a set of training data. The model makes predictions based on new input data. For example, a model that’s been trained on a region’s historical house prices may be able to predict a house’s price when given the number of bedrooms and bathrooms. 训练模型是将机器学习算法应用于一组训练数据的结果。 该模型基于新的输入数据进行预测。 例如，根据某个地区的历史房价进行训练的模型可能能够在给予卧室和浴室的数量时预测房子的价格。
Core ML is the foundation for domain-specific frameworks and functionality. Core ML supports Vision for image analysis, Foundation for natural language processing (for example, the NSLinguisticTagger class), and GameplayKit for evaluating learned decision trees. Core ML itself builds on top of low-level primitives like Accelerate and BNNS, as well as Metal Performance Shaders. CoreML是领域特定语言框架和功能的基础。 CoreML支持视觉图像分析，自然语言处理基础（例如， NSLinguisticTagger 类），以及用于评估学习决策树的GameplayKit。 CoreML本身建立在诸如Accelerate和BNNS（被称为基础神经网络子程序（BNNS，Basic Neural Network Subroutines）以及Metal Performance Shader之类的低级原语之上。
Core ML is optimized for on-device performance, which minimizes memory footprint and power consumption. Running strictly on the device ensures the privacy of user data and guarantees that your app remains functional and responsive when a network connection is unavailable. Core ML针对设备性能进行了优化，最大限度地减少了内存占用和功耗。 严格按照设备运行确保用户数据的隐私，并确保您的应用程序在网络连接不可用时保持功能和响应。
Getting a Core ML Model
Core ML supports a variety of machine learning models, including neural networks, tree ensembles, support vector machines, and generalized linear models. Core ML requires the Core ML model format (models with a .mlmodel file extension). Apple provides several popular, open source models that are already in the Core ML model format. You can download these models machine-learning and start using them in your app. Additionally, various research groups and universities publish their models and training data, which may not be in the Core ML model format. To use these models, you need to convert them, as described in Converting Trained Models to Core ML.
CoreML支持各种机器学习模型，包括神经网络，树组合，支持向量机和广义线性模型。 CoreML需要Core ML模型格式（具有.mlmodel文件扩展名的模型）。 苹果提供了几款流行的开源模型，这些模型已经在Core ML模型格式中。 您可以下载这些模型，并在您的应用程序中开始使用它们。 另外，各研究组和大学发布他们的模型和训练数据，可能不在核CoreML模式格式。 要使用这些模型，您需要转换它们，如将训练模型转换为CoreML所描述的。
Obtain a Core ML model to use in your app.
Integrating a Core ML Model into Your App
Add a simple model to an app, pass input data to the model, and process the model’s predictions.
Model Conversion 模型转换
Converting Trained Models to Core ML Converting Trained Models to Core ML
Convert trained models created with third-party machine learning tools to the Core ML model format.
If your model is created and trained using a supported third-party machine learning tool, you can use Core ML Tools to convert it to the Core ML model format. Table 1 lists the supported models and third-party tools.
Core ML Tools is a Python package (coremltools), hosted at the Python Package Index (PyPI). For information about Python packages, see Python Packaging User Guide.
Core ML API
Use the Core ML API directly to support custom workflows and advanced use cases.
Core ML is an Apple framework which allows developers to simply and easily integrate machine learning (ML) models into apps running on Apple devices (including iOS, watchOS, macOS, and tvOS). Core ML introduces a public file format (.mlmodel) for a broad set of ML methods including deep neural networks (both convolutional and recurrent), tree ensembles with boosting, and generalized linear models. Models in this format can be directly integrated into apps through Xcode.
coremltools in a python package for creating, examining, and testing models in the .mlmodel format. In particular, it can be used to:
Convert existing models to .mlmodel format from popular machine learning tools including Keras, Caffe, scikit-learn, libsvm, and XGBoost.
Express models in .mlmodel format through a simple API.
Make predictions with an .mlmodel (on select platforms for testing purposes).
The method for installing coremltools follows the standard python package installation steps. Once you have set up a python environment, run:
pip install -U coremltools
The package documentation contains more details on how to use coremltools.
coremltools has the following dependencies:
In addition, it has the following soft dependencies that are only needed when you are converting models of these formats:
Keras (==1.2.2) with Tensorflow (1.0.x, 1.1.x)
Core ML framework documentation
Download coremltools documentation
Download Core ML model specification
Machine learning at Apple
Copyright (c) 2017, Apple Inc. All rights reserved.
Use of this source code is governed by the 3-Clause BSD License that can be found in the LICENSE.txt file.