Skip to content

Commit d5426a8

Browse files
xta0Pat Mellon
authored andcommitted
update
1 parent c336250 commit d5426a8

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

_mobile/ios.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,39 @@ To get started with PyTorch on iOS, we recommend exploring the following [HelloW
1616

1717
HelloWorld is a simple image classification application that demonstrates how to use PyTorch C++ libraries on iOS. The code is written in Swift and uses Objective-C as a bridge.
1818

19-
Before we jump into details, we highly recommend following the [Pytorch Github page](https://github.com/pytorch/pytorch) to set up the Python development environment on your local machine.
20-
2119
### Model preparation
2220

23-
Let's start with model preparation. If you are familiar with PyTorch, you probably should already know how to train and save your model. In case you don't, we are going to use a pre-trained image classification model(Resnet18), which is packaged in [TorchVision](https://pytorch.org/docs/stable/torchvision/index.html). To install it, run the command below.
21+
Let's start with model preparation. If you are familiar with PyTorch, you probably should already know how to train and save your model. In case you don't, we are going to use a pre-trained image classification model - Resnet18, which is already packaged in [TorchVision](https://pytorch.org/docs/stable/torchvision/index.html). To install it, run the command below.
22+
23+
> Before running, we highly recommend following the [Pytorch Github page](https://github.com/pytorch/pytorch) to set up the Python development environment on your local machine.
2424
2525
```shell
2626
pip install torchvision
2727
```
2828

29-
Once we have TorchVision installed successfully, let's navigate to the HelloWorld folder and run `trace_model.py` to generate our model. The script contains the code of tracing and saving a [torchscript model](https://pytorch.org/tutorials/beginner/Intro_to_TorchScript_tutorial.html) that can be run on mobile devices. Run the command below to get our model
29+
Once we have TorchVision installed successfully, let's navigate to the HelloWorld folder and run `trace_model.py`. The script contains the code of tracing and saving a [torchscript model](https://pytorch.org/tutorials/beginner/Intro_to_TorchScript_tutorial.html) that can be run on mobile devices.
3030

3131
```shell
3232
python trace_model.py
3333
```
3434

35-
If everything works well, we should have our model - `model.pt` generated in the same folder. Now copy the model file to our application folder `HelloWorld/model`.
35+
If everything works well, we should have our model - `model.pt` generated in the `HelloWorld` folder. Now copy the model file to our application folder `HelloWorld/model`.
3636

37-
More details about TorchScript you can find in [tutorials on pytorch.org](https://pytorch.org/docs/stable/jit.html)
37+
> To find out more details about TorchScript, please visit [tutorials on pytorch.org](https://pytorch.org/docs/stable/jit.html)
3838
3939
### Install PyTorch C++ libraries via Cocoapods
4040

41-
The PyTorch C++ library is available in [Cocoapods](https://cocoapods.org/), to integrate it to our project, we can run
41+
The PyTorch C++ library is available in [Cocoapods](https://cocoapods.org/), to integrate it to our project, simply run
4242

4343
```ruby
4444
pod install
4545
```
46+
4647
Now it's time to open the `HelloWorld.xcworkspace` in XCode, select an iOS simulator and launch it (cmd + R). If everything works well, we should see a wolf picture on the simulator screen along with the prediction result.
4748

4849
### Code Walkthrough
4950

50-
In this part, we are going to walk through the code step by step. All logic happens in `ViewController.swift`.
51+
In this part, we are going to walk through the code step by step.
5152

5253
#### Image loading
5354

@@ -141,7 +142,7 @@ let sortedResults = zippedResults.sorted { $0.1.floatValue > $1.1.floatValue }.p
141142

142143
### PyTorch demo app
143144

144-
For more complex use cases, we recommend to check out the PyTorch demo application. The demo app contains two showcases. A camera app that runs a quantized model to predict the images coming from device’s rear-facing camera in real time. And a text-based app that uses a self-trained NLP model to predict the topic from the input string.
145+
For more complex use cases, we recommend to check out the PyTorch demo application. The demo app contains two showcases. A camera app that runs a quantized model to predict the images coming from device’s rear-facing camera in real time. And a text-based app that uses a text classififcation model to predict the topic from the input string.
145146

146147
## Build PyTorch iOS libraries from source
147148

0 commit comments

Comments
 (0)