You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 16, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+89-7Lines changed: 89 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,96 @@ PyTorch on Android is a project to demo how to use [PyTorch](https://pytorch.org
6
6
7
7
_The source code for the demo in this repo was originally based on [AICamera repo](https://github.com/bwasti/AICamera) unchanged._
8
8
9
-
**Project Status**: Early release. Still in heavy development. What this means is, things might be moved around quickly and things will break.
9
+
**Project Status**:
10
+
11
+
- Early release. Still in heavy development. What this means is, things might be moved around quickly and things will break.
12
+
- 2018-12-31:
13
+
- PyTorch core maintainers have updated AICamera example to work with latest PyTorch master. Once that PR is merged into PyTorch master, you can use the README below to get a working Android app, including changing the Protobuf with your own `init.pb` / `predict.pb` files.
- I have tested the Android OSS fixes with my own `resnet18_init_net_v1.pb` and `resnet18_predict_net_v1.pb` Protobuf files and the Android app is working fine.
10
17
11
18
## Goal
12
19
13
20
Make it easier to ship and test your neural network model in PyTorch on mobile devices.
14
21
15
22
## Documentation
16
23
17
-
We created a developer guide on [how to ship a convolutional neural network on Android with PyTorch and Android Studio](https://github.com/cedrickchee/data-science-notebooks/blob/master/notebooks/deep_learning/fastai_mobile/README.md). Check it out!
24
+
### Updating the AICamera Android app to work with Caffe2 from PyTorch/master
25
+
26
+
This is an example for using Caffe2 on Android.
27
+
28
+
1. git clone PyTorch source and switch to remote branch, `android_oss_fixes`:
# We are using this PyTorch master commit 39381964bbb2686cf84c78aed638985455f6d3fe (Dec 23 02:08:33 2018 -0500, "fix build_android for newest NDK, and make install work")
34
+
$ git checkout --track origin/android_oss_fixes
35
+
36
+
M third_party/QNNPACK
37
+
M third_party/cpuinfo
38
+
M third_party/fbgemm
39
+
M third_party/ideep
40
+
Branch 'android_oss_fixes'set up to track remote branch 'android_oss_fixes' from 'origin'.
41
+
Switched to a new branch 'android_oss_fixes'
42
+
```
43
+
44
+
2. You'll need to download the [Android NDK (latest r18 release)](https://developer.android.com/ndk/downloads/) if you have not.
45
+
46
+
3. First, we will compile Caffe2 Android libraries like libcaffe2, libqnnpack for arm-v7a ABI and then for x86.
47
+
48
+
Set build environment:
49
+
- PyTorch folder is at `$PYTORCH_ROOT`
50
+
- This repository folder is at `$AICAMERA_ROOT`
51
+
- Android NDK folder is at `$ANDROID_NDK`
52
+
53
+
```sh
54
+
# make sure $PYTORCH_ROOT, $AICAMERA_ROOT and $ANDROID_NDK are set
Build Caffe2 android libs and copy them over into AICamera app folder
65
+
66
+
```sh
67
+
./scripts/build_android.sh
68
+
```
69
+
If you encountered build errors related to "quantized/int8_*.cc", get the patch from this "[Update QNNPACK](https://github.com/pytorch/pytorch/pull/15561/files)" PR. Patch these files in your local copies.
70
+
71
+
You should see "Install configuration: "Release"" output in your terminal if the process completed successfully.
3. Build the AICamera app using the `Build -> Make Project` menu option in Android Studio
95
+
96
+
### Developer Guide
97
+
98
+
We created a developer guide on [how to ship a convolutional neural network (Resnet18 and SqueezeNet) on Android with PyTorch and Android Studio](https://github.com/cedrickchee/data-science-notebooks/blob/master/notebooks/deep_learning/fastai_mobile/README.md). Check it out!
18
99
19
100
### Step by Step Guide
20
101
@@ -26,7 +107,7 @@ We'll walk you through every step, from problem all the way to building and depl
26
107
-[x] Test SqueezeNet v1.1 model with your own video stream from camera
27
108
-[x] Live (real-time) detection
28
109
-[ ] Performance optimization
29
-
-[] Test build in models (MobileNetV2, ShuffleNet) with your own video stream from camera
110
+
-[x] Test build in models (MobileNetV2, ShuffleNet, Resnet18) with your own video stream from camera
30
111
-[ ] Download your own model on the fly and test it
31
112
-[ ] Manage models locally on your Android device
32
113
-[ ] Memory consumption and time elapse data
@@ -36,7 +117,7 @@ We'll walk you through every step, from problem all the way to building and depl
36
117
-[ ] New classifier for insect species dataset using pre-trained ImageNet weights (transfer learning)
37
118
-[ ] Upload pre-trained models
38
119
-[ ] Bug fixes
39
-
-[] Fix intermittent crashes
120
+
-[x] Fix intermittent crashes
40
121
-[ ] React Native native module
41
122
42
123
## Android Project
@@ -49,17 +130,18 @@ You can download the Android project source code by running this command:
0 commit comments