@@ -10,23 +10,23 @@ There's a comprehensive [Tutorial](https://github.com/onnx/tutorials/tree/master
10
10
## [ New] Beta onnx-coreml converter with Core ML 3
11
11
12
12
To try out the new beta converter with CoreML 3 (>= iOS 13, >= macOS 15),
13
- install coremltools 3.0b3 and coremltools 1.0b3
13
+ install coremltools 3.0b6 and coremltools 1.0b3
14
14
15
15
``` shell
16
16
pip install coremltools==3.0b6
17
17
pip install onnx-coreml==1.0b3
18
18
```
19
19
20
- With beta 3, flag ` disable_coreml_rank5_mapping ` which should be set to true to utilize
21
- the Core ML 3 specification is removed and replace by target iOS specific flag, taking default value of '12'
20
+ In beta 3, the flag ` disable_coreml_rank5_mapping ` ( which was part of beta 2) has been removed and instead replaced by
21
+ the generic argument ` target_ios ` which can be used to target different versions of CoreML/iOS.
22
22
23
- target_ios takes a string specifying target deployment iOS version e.g. '11.2', '12' and '13'
23
+ ` target_ios ` takes a string specifying target deployment iOS version e.g. '11.2', '12' and '13'.
24
+ By default, the converter uses the value of '12'.
24
25
25
26
For example:
26
27
``` python
27
28
from onnx_coreml import convert
28
-
29
- ml_model = convert(model = ' my_model.onnx' , target_ios = ' 13' )
29
+ ml_model = convert(model = ' my_model.onnx' , target_ios = ' 13' ) # to use CoreML 3
30
30
```
31
31
32
32
## Installation
@@ -81,7 +81,8 @@ def convert(model,
81
81
predicted_feature_name = ' classLabel' ,
82
82
add_custom_layers = False ,
83
83
custom_conversion_functions = {},
84
- target_ios = ' 12' )
84
+ target_ios = ' 12'
85
+ )
85
86
```
86
87
87
88
The function returns a coreml model instance that can be saved to a .mlmodel file, e.g.:
@@ -160,22 +161,23 @@ __custom_conversion_fuctions__: dict (str: function)
160
161
Examples: https://github.com/onnx/onnx-coreml/blob/master/tests/custom_layers_test.py#L43
161
162
162
163
__ onnx_coreml_input_shape_map__ : dict (str: List[ int] )
163
- (Optional) A dictionary with keys corresponding to the model input names. Values are a list of integers that specify
164
+ (Optional)
165
+ (only used if ` target_ios ` version is less than '13')
166
+ A dictionary with keys corresponding to the model input names. Values are a list of integers that specify
164
167
how the shape of the input is mapped to CoreML. Convention used for CoreML shapes is:
165
168
0: Sequence, 1: Batch, 2: channel, 3: height, 4: width.
166
169
For example, an input of rank 2 could be mapped as [ 3,4] (i.e. H,W) or [ 1,2] (i.e. B,C) etc.
167
170
168
- __ target_ios__ : str
169
- Target Deployment iOS Version (default: '12')
170
- Supported iOS version options : '11.2', '12', '13'
171
+ __ target_ios__ : str
172
+ Target Deployment iOS version (default: '12')
173
+ Supported values : '11.2', '12', '13'
171
174
CoreML model produced by the converter will be compatible with the iOS version specified in this argument.
172
- e.g. if target_ios = '12', the converter would only utilize CoreML features released till iOS12 (equivalently macOS 10.14, watchOS 5 etc).
173
-
174
- - (Supported features: https://github.com/apple/coremltools/releases/tag/v0.8)
175
- iOS 12 (CoreML 2.0)
176
- - (Supported features: https://github.com/apple/coremltools/releases/tag/v2.0)
177
- iSO 13 (CoreML 3.0)
178
- - (Supported features: https://github.com/apple/coremltools/releases/tag/3.0-beta6)
175
+ e.g. if ` target_ios ` = '12', the converter would only utilize CoreML features released till iOS12
176
+ (equivalently macOS 10.14, watchOS 5 etc).
177
+ Release notes:
178
+ * iOS 11 / CoreML 1: https://github.com/apple/coremltools/releases/tag/v0.8
179
+ * iOS 12 / CoreML 2: https://github.com/apple/coremltools/releases/tag/v2.0
180
+ * iOS 13 / CoreML 3: https://github.com/apple/coremltools/releases/tag/v3.0-beta
179
181
180
182
### Returns
181
183
__ model__ : A coreml model.
0 commit comments