Skip to content

Commit 9ba04eb

Browse files
authored
Merge pull request #918 from pytorch/sdym/update-ios
Update ios.md
2 parents 3a95b64 + ccaeb9c commit 9ba04eb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

_mobile/ios.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ 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+
### Requirements
20+
21+
- XCode 11.0 or above
22+
- iOS 12.0 or above
23+
1924
### Model Preparation
2025

2126
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 - [MobileNet v2](https://pytorch.org/hub/pytorch_vision_mobilenet_v2/), which is already packaged in [TorchVision](https://pytorch.org/docs/stable/torchvision/index.html). To install it, run the command below.
@@ -32,7 +37,7 @@ Once we have TorchVision installed successfully, let's navigate to the HelloWorl
3237
python trace_model.py
3338
```
3439

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`.
40+
If everything works well, `model.pt` should be generated and saved in the `HelloWorld/HelloWorld/model` folder.
3641

3742
> To find out more details about TorchScript, please visit [tutorials on pytorch.org](https://pytorch.org/tutorials/advanced/cpp_export.html)
3843
@@ -65,7 +70,7 @@ guard var pixelBuffer = resizedImage.normalized() else {
6570
}
6671
```
6772

68-
We first load the image from our bundle and resize it to 224x224. Then we call this `normalized()` category method to normalized the pixel buffer. Let's take a closer look at the code below.
73+
We first load the image from our bundle and resize it to 224x224. Then we call this `normalized()` category method to normalize the pixel buffer. Let's take a closer look at the code below.
6974

7075
```swift
7176
var normalizedBuffer: [Float32] = [Float32](repeating: 0, count: w * h * 3)
@@ -82,7 +87,7 @@ The code might look weird at first glance, but it’ll make sense once we unders
8287

8388
#### TorchScript Module
8489

85-
Now that we have preprocessed our input data and we have a pre-trained TorchScript model, the next step is to use them to run predication. To do that, we'll first load our model into the application.
90+
Now that we have preprocessed our input data and we have a pre-trained TorchScript model, the next step is to use them to run prediction. To do that, we'll first load our model into the application.
8691

8792
```swift
8893
private lazy var module: TorchModule = {

0 commit comments

Comments
 (0)