Skip to content

Commit

Permalink
[Android] Support PPTinyPose on Android (#746)
Browse files Browse the repository at this point in the history
* [Android] Update ppseg jni via new api and optimize jni vis funcs

* delete local refs

* [Android] Add PPTinyPose jni and java api

* [Android] Update gradle download tasks info

* [Android] Add PPTinyPose Android app example

* update app build.gradle
  • Loading branch information
DefTruth authored Nov 30, 2022
1 parent 9d78b1d commit 8e4a38c
Show file tree
Hide file tree
Showing 27 changed files with 1,641 additions and 42 deletions.
24 changes: 16 additions & 8 deletions java/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
Expand Down Expand Up @@ -69,6 +68,10 @@ def FD_MODEL = [
[
'src' : 'https://bj.bcebos.com/paddlehub/fastdeploy/portrait_pp_humansegv2_lite_256x144_inference_model.tgz',
'dest': 'src/main/assets/models'
],
[
'src' : 'https://bj.bcebos.com/paddlehub/fastdeploy/PP_TinyPose_128x96_infer.tgz',
'dest': 'src/main/assets/models'
]
]

Expand All @@ -81,7 +84,7 @@ def FD_JAVA_SDK = [

task downloadAndExtractModels(type: DefaultTask) {
doFirst {
println "Downloading and extracting fastdeploy models ..."
println "[INFO] Downloading and extracting fastdeploy models ..."
}
doLast {
String cachePath = "cache"
Expand All @@ -91,27 +94,30 @@ task downloadAndExtractModels(type: DefaultTask) {
FD_MODEL.eachWithIndex { model, index ->
String[] modelPaths = model.src.split("/")
String modelName = modelPaths[modelPaths.length - 1]
String modelPrefix = modelName.substring(0, modelName.length() - 4)
// Download the target model if not exists
boolean copyFiles = !file("${model.dest}").exists()
boolean copyFiles = !file("${model.dest}/${modelPrefix}").exists()
if (!file("${cachePath}/${modelName}").exists()) {
println "Downloading ${model.src} -> ${cachePath}/${modelName}"
println "[INFO] Downloading ${model.src} -> ${cachePath}/${modelName}"
ant.get(src: model.src, dest: file("${cachePath}/${modelName}"))
copyFiles = true
}
if (copyFiles) {
println "Coping ${cachePath}/${modelName} -> ${model.dest}"
println "[INFO] Taring ${cachePath}/${modelName} -> ${model.dest}/${modelPrefix}"
copy {
from tarTree("${cachePath}/${modelName}")
into "${model.dest}"
}
} else {
println "[INFO] ${model.dest}/${modelPrefix} already exists!"
}
}
}
}

task downloadAndExtractSDKs(type: DefaultTask) {
doFirst {
println "Downloading and extracting fastdeploy android java sdk ..."
println "[INFO] Downloading and extracting fastdeploy android java sdk ..."
}
doLast {
String cachePath = "cache"
Expand All @@ -124,16 +130,18 @@ task downloadAndExtractSDKs(type: DefaultTask) {
// Download the target SDK if not exists
boolean copyFiles = !file("${sdk.dest}/${sdkName}").exists()
if (!file("${cachePath}/${sdkName}").exists()) {
println "Downloading ${sdk.src} -> ${cachePath}/${sdkName}"
println "[INFO] Downloading ${sdk.src} -> ${cachePath}/${sdkName}"
ant.get(src: sdk.src, dest: file("${cachePath}/${sdkName}"))
copyFiles = true
}
if (copyFiles) {
println "Coping ${cachePath}/${sdkName} -> ${sdk.dest}/${sdkName}"
println "[INFO] Coping ${cachePath}/${sdkName} -> ${sdk.dest}/${sdkName}"
copy {
from "${cachePath}/${sdkName}"
into "${sdk.dest}"
}
} else {
println "[INFO] ${sdk.dest}/${sdkName} already exists!"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions java/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".segmentation.SegmentationMainActivity">
<activity android:name=".keypointdetection.KeyPointDetectionMainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".segmentation.SegmentationSettingsActivity"
android:name=".keypointdetection.KeyPointDetectionSettingsActivity"
android:label="Settings">
</activity>
</application>
Expand Down
Loading

0 comments on commit 8e4a38c

Please sign in to comment.