Skip to content

Commit 303273b

Browse files
author
Wenbing Li
authored
Update README.md
1 parent d2c8fb7 commit 303273b

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,6 @@ ONNXMLTools has been tested with Python **2.7**, **3.5**, **3.6**, and **3.7**.
4343
# Examples
4444
If you want the converted ONNX model to be compatible with a certain ONNX version, please specify the target_opset parameter upon invoking the convert function. The following Keras model conversion example demonstrates this below. You can identify the mapping from ONNX Operator Sets (referred to as opsets) to ONNX releases in the [versioning documentation](https://github.com/onnx/onnx/blob/master/docs/Versioning.md#released-versions).
4545

46-
## CoreML to ONNX Conversion
47-
Here is a simple code snippet to convert a Core ML model into an ONNX model.
48-
49-
```python
50-
import onnxmltools
51-
import coremltools
52-
53-
# Load a Core ML model
54-
coreml_model = coremltools.utils.load_spec('example.mlmodel')
55-
56-
# Convert the Core ML model into ONNX
57-
onnx_model = onnxmltools.convert_coreml(coreml_model, 'Example Model')
58-
59-
# Save as protobuf
60-
onnxmltools.utils.save_model(onnx_model, 'example.onnx')
61-
```
62-
6346
## Keras to ONNX Conversion
6447
Next, we show an example of converting a Keras model into an ONNX model with `target_opset=7`, which corresponds to ONNX release version 1.2.
6548

@@ -93,7 +76,24 @@ keras_model = Model(inputs=[input1, input2], output=sub_sum)
9376
onnx_model = onnxmltools.convert_keras(keras_model, target_opset=7)
9477
```
9578

96-
## Spark ML to ONNX Conversion
79+
## CoreML to ONNX Conversion
80+
Here is a simple code snippet to convert a Core ML model into an ONNX model.
81+
82+
```python
83+
import onnxmltools
84+
import coremltools
85+
86+
# Load a Core ML model
87+
coreml_model = coremltools.utils.load_spec('example.mlmodel')
88+
89+
# Convert the Core ML model into ONNX
90+
onnx_model = onnxmltools.convert_coreml(coreml_model, 'Example Model')
91+
92+
# Save as protobuf
93+
onnxmltools.utils.save_model(onnx_model, 'example.onnx')
94+
```
95+
96+
## Spark ML to ONNX Conversion (experimental)
9797
Please refer to the following documents:
9898
* [Conversion Framework](onnxmltools/convert/README.md)
9999
* [Spark ML to ONNX Model Conversion](onnxmltools/convert/sparkml/README.md)

0 commit comments

Comments
 (0)