Skip to content

Commit 39539f9

Browse files
authored
Update README.md
1 parent f0da298 commit 39539f9

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

examples/CoreML/ONNXLive/README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ONNXLive Tutorial:
2-
This tutorial will show you to convert a neural style transfer model that has been exported from PyTorch and into the Apple Core ML format using ONNX. THis will allow you to easily run deep learning models on Apple devices and, in this case, live stream from the camera.
2+
This tutorial will show you to convert a neural style transfer model that has been exported from PyTorch and into the Apple CoreML format using ONNX. THis will allow you to easily run deep learning models on Apple devices and, in this case, live stream from the camera.
33

44
## What is ONNX?
55
ONNX (Open Neural Network Exchange is an open format to represent deep learning models. With ONNX, AI developers can more easily move models between state-of-the-art tools and choose the combination that is best for them. ONNX is developed and supported by a community of partners. You can learn more about ONNX and what tools are supported by going to [onnx.ai](http://onnx.ai/).
@@ -86,17 +86,16 @@ created from the corresponding `.pth` files.
8686

8787
## Convert the ONNX models to CoreML models
8888

89-
Now that we have the ONNX models, we can convert them to CoreML models to run on iOS devices.
89+
Now that we have ONNX models, we can convert them to CoreML models in order to run them on Apple devices.
9090
For this, we use the onnx-coreml converter we installed previously.
91-
The converter comes with a `convert-onnx-to-coreml` script, which the installation steps above added to our path,
92-
but unfortunately that doesn't work for us, because we need to mark the input and output of the network as an image
93-
and while this is supported by the converter, it is only supported when calling the converter from python.
91+
The converter comes with a `convert-onnx-to-coreml` script, which the installation steps above added to our path. Unfortunately that won't work for us as we need to mark the input and output of the network as an image
92+
and, while this is supported by the converter, it is only supported when calling the converter from python.
9493

9594
Looking at the style transfer model (for example opening the .onnx file in an application like [Netron](https://github.com/lutzroeder/Netron)),
9695
we see that the input is named '0' and the output is named '186'. These are just numeric ids assigned by PyTorch.
97-
These are the ones we need to mark as images.
96+
We will need to mark these as images.
9897

99-
So let's write a small python file `onnx_to_coreml.py`
98+
So let's create a small python file and call it `onnx_to_coreml.py`. This can be created by using the touch command and edited with your favorite editor to add the following lines of code.
10099

101100
import sys
102101
from onnx import onnx_pb2
@@ -111,7 +110,7 @@ So let's write a small python file `onnx_to_coreml.py`
111110
coreml_model = convert(model_proto, image_input_names=['0'], image_output_names=['186'])
112111
coreml_model.save(model_out)
113112

114-
and run it
113+
we now run it
115114

116115
python onnx_to_coreml.py ./saved_models/candy.onnx ./saved_models/candy.mlmodel
117116
python onnx_to_coreml.py ./saved_models/udnie.onnx ./saved_models/udnie.mlmodel
@@ -122,8 +121,7 @@ Now, there should be 4 CoreML models in your `saved_models` directory: `candy.ml
122121

123122
## Run the CoreML models in a style transfer iOS App
124123

125-
This repository (i.e. the one you're currently reading the README.md of) contains an iOS app able to run CoreML style transfer models
126-
on a live camera stream from your phone camera. Let's clone the repository
124+
This repository (i.e. the one you're currently reading the README.md of) contains an iOS app able to run CoreML style transfer models on a live camera stream from your phone camera. Let's clone the repository
127125

128126
git clone https://github.com/onnx/tutorials
129127

@@ -132,12 +130,13 @@ We recommend using XCode 9.3 and an iPhone X. There might be issues running on o
132130

133131
In the `Models/` folder, the project contains some .mlmodel files. We're going to replace them with the models we just created.
134132

135-
Then, run the app on your iPhone and your all set. Tapping on the screen switches through the models.
133+
You then, run the app on your iPhone and you are all set. Tapping on the screen switches through the models.
136134

137135
## Conclusion
138136

139137
We hope this tutorial gave you an overview of what ONNX is about and how you can use it to convert neural networks
140-
between frameworks, in this case a few style transfer models from PyTorch to CoreML.
138+
between frameworks, in this case neural style transfer models moving from PyTorch to CoreML.
141139

142140
Feel free to experiment with these steps and test them on your own models.
143141
Please let us know if you hit any issues or want to give feedback. We'd like to hear what you think.
142+

0 commit comments

Comments
 (0)