Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

fix "Lite Interpreter verson number does not match" #271

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions HelloWorldApp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ This application runs TorchScript serialized TorchVision pretrained [MobileNet v

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 v3), which is packaged in [TorchVision](https://pytorch.org/docs/stable/torchvision/index.html).
To install it, run the command below:
```
pip install torch torchvision
```sh
pip install torch==1.8.2 torchvision==0.9.2
# or
pip install -r requirements.txt
# maybe faster
pip install torch==1.8.2 torchvision==0.9.2 -extra-index-url https://download.pytorch.org/whl/lts/1.8/cpu
```

To serialize and optimize the model for Android, you can use the Python [script](https://github.com/pytorch/android-demo-app/blob/master/HelloWorldApp/trace_model.py) in the root folder of HelloWorld app:
Expand Down Expand Up @@ -54,14 +58,14 @@ repositories {
}

dependencies {
implementation 'org.pytorch:pytorch_android_lite:1.9.0'
implementation 'org.pytorch:pytorch_android_torchvision:1.9.0'
implementation 'org.pytorch:pytorch_android_lite:1.12.2'
implementation 'org.pytorch:pytorch_android_torchvision_lite:1.12.2'
}
```
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).
Where `org.pytorch:pytorch_android_lite` is the main dependency with PyTorch Android API, including libtorch native library for all 4 android abis (armeabi-v7a, arm64-v8a, x86, x86_64).
Further in this doc you can find how to rebuild it only for specific list of android abis.

`org.pytorch:pytorch_android_torchvision` - additional library with utility functions for converting `android.media.Image` and `android.graphics.Bitmap` to tensors.
`org.pytorch:pytorch_android_torchvision_lite` - additional library with utility functions for converting `android.media.Image` and `android.graphics.Bitmap` to tensors.

#### 4. Reading image from Android Asset

Expand Down
10 changes: 5 additions & 5 deletions HelloWorldApp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "org.pytorch.helloworld"
applicationId 'org.pytorch.helloworld'
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionName '1.0'
}
buildTypes {
release {
Expand All @@ -19,6 +19,6 @@ android {

dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'org.pytorch:pytorch_android_lite:1.9.0'
implementation 'org.pytorch:pytorch_android_torchvision:1.9.0'
implementation 'org.pytorch:pytorch_android_lite:1.12.2'
implementation 'org.pytorch:pytorch_android_torchvision_lite:1.12.2'
}
2 changes: 2 additions & 0 deletions HelloWorldApp/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
torch==1.8.2
torchvision==0.9.2