Skip to content

Commit 066b935

Browse files
authored
Update README.md (#12)
* Update README.md * Update README.md
1 parent 525323a commit 066b935

File tree

1 file changed

+2
-107
lines changed

1 file changed

+2
-107
lines changed

apple/ExecuTorchDemo/README.md

Lines changed: 2 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -2,113 +2,8 @@
22

33
This app uses the [MobileNet v3](https://pytorch.org/vision/main/models/mobilenetv3.html) model to process live camera images leveraging three different backends: [XNNPACK](https://github.com/google/XNNPACK), [Core ML](https://developer.apple.com/documentation/coreml) and [Metal Performance Shaders (MPS)](https://developer.apple.com/documentation/metalperformanceshaders) (Xcode 15+ and iOS 17+ only).
44

5+
Please refer to the [documentation](https://pytorch.org/executorch/main/demo-apps-ios.html) on how to build and run this app.
6+
57
<p align="center">
68
<img src="https://github.com/user-attachments/assets/69f4cc2c-a95e-4e01-ba4d-7e40791716c8" width="50%">
79
</p>
8-
9-
## Prerequisites
10-
11-
Before we start, make sure you have the following tools installed:
12-
13-
### 1. Xcode 15+ and Command Line Tools
14-
15-
Install Xcode 15+ from the
16-
[Mac App Store](https://apps.apple.com/app/xcode/id497799835) and then install
17-
the Command Line Tools using the terminal:
18-
19-
```bash
20-
xcode-select --install
21-
```
22-
23-
### 2. Python 3.10+
24-
25-
Python 3.10 or above, along with `pip3`, should be pre-installed on MacOS 13.5+.
26-
If needed, [download Python](https://www.python.org/downloads/macos/) and
27-
install it. Verify the Python and pip versions using these commands:
28-
29-
```bash
30-
which python3 pip3
31-
python3 --version
32-
pip3 --version
33-
```
34-
35-
## Models and Labels
36-
37-
Now, let's move on to exporting and bundling the MobileNet v3 model.
38-
39-
### 1. Set Up ExecuTorch
40-
41-
Clone ExecuTorch and configure the basic environment:
42-
43-
```bash
44-
git clone https://github.com/pytorch/executorch.git --depth 1 && cd executorch && \
45-
python3 -m venv .venv && source .venv/bin/activate && pip3 install --upgrade pip && cd - && \
46-
./executorch/install_executorch.sh
47-
```
48-
49-
### 2. Install Backend Dependencies
50-
51-
Install additional dependencies for Core ML and MPS backends:
52-
53-
```bash
54-
./executorch/backends/apple/coreml/scripts/install_requirements.sh && \
55-
./executorch/backends/apple/mps/install_requirements.sh
56-
```
57-
58-
### 3. Export Model
59-
60-
Export the MobileNet v3 model with Core ML, MPS and XNNPACK backends:
61-
62-
```bash
63-
MODEL_NAME="mv3"
64-
cd executorch && \
65-
python3 -m examples.portable.scripts.export --model_name="$MODEL_NAME" && \
66-
python3 -m examples.apple.coreml.scripts.export --model_name="$MODEL_NAME" && \
67-
python3 -m examples.apple.mps.scripts.mps_example --model_name="$MODEL_NAME" && \
68-
python3 -m examples.xnnpack.aot_compiler --model_name="$MODEL_NAME" --delegate && \
69-
cd -
70-
```
71-
72-
Move the exported model files (those with `.pte` extension) to a specific location where the Demo App will pick them up:
73-
74-
```bash
75-
mkdir -p apple/ExecuTorchDemo/ExecuTorchDemo/Resources/Models/MobileNet/ && \
76-
mv executorch/"$MODEL_NAME"*.pte apple/ExecuTorchDemo/ExecuTorchDemo/Resources/Models/MobileNet/
77-
```
78-
79-
### 4. Download Labels
80-
81-
Download the MobileNet model labels required for image classification:
82-
83-
```bash
84-
curl https://github.com/raw/pytorch/hub/master/imagenet_classes.txt \
85-
-o apple/ExecuTorchDemo/ExecuTorchDemo/Resources/Models/MobileNet/imagenet_classes.txt
86-
```
87-
88-
## Final Steps
89-
90-
Now, we just need to open the project in Xcode, run the tests, and finally run the app.
91-
Double-click on the project file under `apple/ExecuTorchDemo` to open it with Xcode, or run the command:
92-
93-
```bash
94-
open apple/ExecuTorchDemo/ExecuTorchDemo.xcodeproj
95-
```
96-
97-
### 1. Run Tests
98-
99-
You can run tests on Simulaltor directly in Xcode with `Cmd + U` or use the command line:
100-
101-
```bash
102-
xcrun simctl create executorch "iPhone 15" && \
103-
xcodebuild clean test \
104-
-project apple/ExecuTorchDemo/ExecuTorchDemo.xcodeproj \
105-
-scheme App \
106-
-destination name=executorch && \
107-
xcrun simctl delete executorch
108-
```
109-
110-
### 2. Run App
111-
112-
Finally, connect the device, set up Code Signing in Xcode, and then run the app using `Cmd + R`. Try installing a Release build for better performance.
113-
114-
Learn more about integrating and running [ExecuTorch on Apple](https://pytorch.org/executorch/main/using-executorch-ios.html) platforms.

0 commit comments

Comments
 (0)