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

fix/HelloWorld-App #281

Open
wants to merge 3 commits 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
4 changes: 2 additions & 2 deletions HelloWorldApp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ 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.13.0'
implementation 'org.pytorch:pytorch_android_torchvision:1.13.0'
}
```
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).
Expand Down
17 changes: 12 additions & 5 deletions HelloWorldApp/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
compileSdkVersion 33
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "org.pytorch.helloworld"
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 33
versionCode 1
versionName "1.0"
}
Expand All @@ -18,7 +18,14 @@ 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 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.facebook.fbjni:fbjni-java-only:0.0.3'

implementation 'org.pytorch:pytorch_android_lite:1.13.0'
implementation 'org.pytorch:pytorch_android_torchvision_lite:1.13.0'

// Uncomment below lines for using libs built from src
// implementation(name:'pytorch_android-release', ext:'aar')
// implementation(name:'pytorch_android_torchvision-release', ext:'aar')

}
3 changes: 2 additions & 1 deletion HelloWorldApp/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Binary file modified HelloWorldApp/app/src/main/assets/model.pt
Binary file not shown.
10 changes: 6 additions & 4 deletions HelloWorldApp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.5.4'
}
}

allprojects {
repositories {
google()
jcenter()

mavenCentral()
flatDir {
dirs 'libs'
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion HelloWorldApp/trace_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import torchvision
from torch.utils.mobile_optimizer import optimize_for_mobile

model = torchvision.models.mobilenet_v3_small(pretrained=True)
model = torchvision.models.mobilenet_v3_small(weights=torchvision.models.MobileNet_V3_Small_Weights.DEFAULT, progress=True)
model.eval()
example = torch.rand(1, 3, 224, 224)
traced_script_module = torch.jit.trace(model, example)
Expand Down