mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 08:37:06 +08:00
[Android] add fastdeploy android sdk download task (#646)
* [Bug Fix] fix android app detail page errors * [Android] fix realtime camera mode and shutter * [Bug Fix] fix AllocateSegmentationResultFromJava error * [Bug Fix] fix camera preview size setting problem * [Model] use uint8 buffer instead of fp32 in ppseg postprocess * [Model] revert changes in ppseg * [Model] revert postprocess changes in ppseg * [Android] add fastdeploy android sdk download task
This commit is contained in:
@@ -25,33 +25,39 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation fileTree(include: ['*.aar'], dir: 'libs')
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0'
|
||||
//noinspection GradleDependency
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
implementation 'com.android.support:design:28.0.0'
|
||||
implementation 'org.jetbrains:annotations:15.0'
|
||||
implementation project(path: ':fastdeploy')
|
||||
//noinspection GradleDependency
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
}
|
||||
|
||||
def archives = [
|
||||
def FD_MODEL = [
|
||||
[
|
||||
'src': 'https://bj.bcebos.com/paddlehub/fastdeploy/picodet_s_320_coco_lcnet.tgz',
|
||||
'dest' : 'src/main/assets/models'
|
||||
'src' : 'https://bj.bcebos.com/paddlehub/fastdeploy/picodet_s_320_coco_lcnet.tgz',
|
||||
'dest': 'src/main/assets/models'
|
||||
],
|
||||
[
|
||||
'src': 'https://bj.bcebos.com/paddlehub/fastdeploy/picodet_l_320_coco_lcnet.tgz',
|
||||
'dest' : 'src/main/assets/models'
|
||||
'src' : 'https://bj.bcebos.com/paddlehub/fastdeploy/picodet_l_320_coco_lcnet.tgz',
|
||||
'dest': 'src/main/assets/models'
|
||||
]
|
||||
]
|
||||
|
||||
task downloadAndExtractArchives(type: DefaultTask) {
|
||||
def FD_JAVA_SDK = [
|
||||
[
|
||||
'src' : 'https://bj.bcebos.com/fastdeploy/test/fastdeploy-android-sdk-latest-dev.aar',
|
||||
'dest': 'libs'
|
||||
]
|
||||
]
|
||||
|
||||
task downloadAndExtractModels(type: DefaultTask) {
|
||||
doFirst {
|
||||
println "Downloading and extracting archives including models ..."
|
||||
println "Downloading and extracting fastdeploy models ..."
|
||||
}
|
||||
doLast {
|
||||
// Prepare cache folder for archives
|
||||
@@ -59,24 +65,63 @@ task downloadAndExtractArchives(type: DefaultTask) {
|
||||
if (!file("${cachePath}").exists()) {
|
||||
mkdir "${cachePath}"
|
||||
}
|
||||
archives.eachWithIndex { archive, index ->
|
||||
FD_MODEL.eachWithIndex { model, index ->
|
||||
MessageDigest messageDigest = MessageDigest.getInstance('MD5')
|
||||
messageDigest.update(archive.src.bytes)
|
||||
messageDigest.update(model.src.bytes)
|
||||
String cacheName = new BigInteger(1, messageDigest.digest()).toString(32)
|
||||
// Download the target archive if not exists
|
||||
boolean copyFiles = !file("${archive.dest}").exists()
|
||||
boolean copyFiles = !file("${model.dest}").exists()
|
||||
if (!file("${cachePath}/${cacheName}.tgz").exists()) {
|
||||
ant.get(src: archive.src, dest: file("${cachePath}/${cacheName}.tgz"))
|
||||
copyFiles = true // force to copy files from the latest archive files
|
||||
println "Downloading ${model.src} -> ${cachePath}/${cacheName}.tgz"
|
||||
ant.get(src: model.src, dest: file("${cachePath}/${cacheName}.tgz"))
|
||||
copyFiles = true
|
||||
// force to copy files from the latest archive files
|
||||
}
|
||||
// Extract the target archive if its dest path does not exists
|
||||
if (copyFiles) {
|
||||
println "Coping ${cachePath}/${cacheName}.aar -> ${model.dest}"
|
||||
copy {
|
||||
from tarTree("${cachePath}/${cacheName}.tgz")
|
||||
into "${archive.dest}"
|
||||
into "${model.dest}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
preBuild.dependsOn downloadAndExtractArchives
|
||||
|
||||
task downloadAndExtractSDKs(type: DefaultTask) {
|
||||
doFirst {
|
||||
println "Downloading and extracting fastdeploy android java sdk ..."
|
||||
}
|
||||
doLast {
|
||||
// Prepare cache folder for archives
|
||||
String cachePath = "cache"
|
||||
if (!file("${cachePath}").exists()) {
|
||||
mkdir "${cachePath}"
|
||||
}
|
||||
FD_JAVA_SDK.eachWithIndex { sdk, index ->
|
||||
String[] sdkPaths = sdk.src.split("/")
|
||||
// e.g fastdeploy-android-sdk-latest-dev.aar
|
||||
String sdkName = sdkPaths[sdkPaths.length - 1]
|
||||
// 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}"
|
||||
ant.get(src: sdk.src, dest: file("${cachePath}/${sdkName}"))
|
||||
copyFiles = true
|
||||
// force to copy files from the latest downloaded sdk
|
||||
}
|
||||
// Copy the target archive if its dest path does not exists
|
||||
if (copyFiles) {
|
||||
println "Coping ${cachePath}/${sdkName} -> ${sdk.dest}/${sdkName}"
|
||||
copy {
|
||||
from "${cachePath}/${sdkName}"
|
||||
into "${sdk.dest}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preBuild.dependsOn downloadAndExtractSDKs
|
||||
preBuild.dependsOn downloadAndExtractModels
|
@@ -35,7 +35,7 @@
|
||||
<!-- facedet values ... -->
|
||||
<string name="FACEDET_MODEL_DIR_DEFAULT">models/scrfd_500m_bnkps_shape320x320_pd</string>
|
||||
<!-- segmentation values ... -->
|
||||
<string name="SEGMENTATION_MODEL_DIR_DEFAULT">models/portrait_pp_humansegv2_lite_256x144_inference_model</string>
|
||||
<string name="SEGMENTATION_MODEL_DIR_DEFAULT">models/human_pp_humansegv1_lite_192x192_inference_model</string>
|
||||
<!-- Other resources values-->
|
||||
<string name="action_bar_take_photo">拍照识别</string>
|
||||
<string name="action_bar_realtime">实时识别</string>
|
||||
|
Reference in New Issue
Block a user