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
Copy file name to clipboardExpand all lines: _mobile/android.md
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ This application runs TorchScript serialized TorchVision pretrained resnet18 mod
17
17
18
18
#### 1. Model Preparation
19
19
20
-
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](https://pytorch.org/hub/pytorch_vision_resnet/)), which is packaged in [TorchVision](https://pytorch.org/docs/stable/torchvision/index.html).
20
+
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 ([MobileNetV2](https://pytorch.org/hub/pytorch_vision_mobilenet_v2/)).
21
21
To install it, run the command below:
22
22
```
23
23
pip install torchvision
@@ -27,12 +27,14 @@ To serialize the model you can use python [script](https://github.com/pytorch/an
27
27
```
28
28
import torch
29
29
import torchvision
30
+
from torch.utils.mobile_optimizer import optimize_for_mobile
30
31
31
-
model = torchvision.models.resnet18(pretrained=True)
32
+
model = torchvision.models.mobilenet_v2(pretrained=True)
Where `org.pytorch:pytorch_android` is the main dependency with PyTorch Android API, including libtorch native library for all 4 android abis (armeabi-v7a, arm64-v8a, x86, x86_64).
0 commit comments