apply plugin: 'com.android.application' android { compileSdk 28 defaultConfig { applicationId 'com.baidu.paddle.fastdeploy.app.examples' minSdkVersion 16 //noinspection ExpiredTargetSdkVersion targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(include: ['*.aar'], dir: 'libs') //noinspection GradleCompatible 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') implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0' implementation project(path: ':ui') //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 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/MobileNetV1_x0_25_infer.tgz', 'dest': 'src/main/assets/models' ], [ 'src' : 'https://bj.bcebos.com/paddlehub/fastdeploy/ch_PP-OCRv2_det_infer.tgz', 'dest': 'src/main/assets/models' ], [ 'src' : 'https://bj.bcebos.com/paddlehub/fastdeploy/ch_ppocr_mobile_v2.0_cls_infer.tgz', 'dest': 'src/main/assets/models' ], [ 'src' : 'https://bj.bcebos.com/paddlehub/fastdeploy/ch_PP-OCRv2_rec_infer.tgz', 'dest': 'src/main/assets/models' ], [ 'src' : 'https://bj.bcebos.com/paddlehub/fastdeploy/yolov5face-n-0.5-320x320_pd.tgz', 'dest': 'src/main/assets/models' ], [ 'src' : 'https://bj.bcebos.com/paddlehub/fastdeploy/scrfd_500m_bnkps_shape320x320_pd.tgz', 'dest': 'src/main/assets/models' ], [ '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' ], [ 'src' : 'https://bj.bcebos.com/paddlehub/fastdeploy/uie-nano.tgz', 'dest': 'src/main/assets/models' ] ] def FD_JAVA_SDK = [ [ 'src' : 'https://bj.bcebos.com/fastdeploy/dev/android/fastdeploy-android-sdk-with-text-0.0.0.aar', 'dest': 'libs', 'name': 'fastdeploy-android-sdk-latest-dev.aar' ], [ 'src' : 'https://bj.bcebos.com/fastdeploy/test/bdasr_V3_20210628_cfe8c44.aar', 'dest': 'libs', 'name': 'bdasr_V3_20210628_cfe8c44.aar' ] ] task downloadAndExtractModels(type: DefaultTask) { doFirst { println "[INFO] Downloading and extracting fastdeploy models ..." } doLast { String cachePath = "cache" if (!file("${cachePath}").exists()) { mkdir "${cachePath}" } FD_MODEL.eachWithIndex { model, index -> String[] modelPaths = model.src.split("/") String modelName = modelPaths[modelPaths.length - 1] String modelPrefix = modelName.substring(0, modelName.length() - 4) boolean copyFiles = false if (!file("${model.dest}/${modelPrefix}").exists()) { // Download the target model if not exists if (!file("${cachePath}/${modelName}").exists()) { println "[INFO] Downloading ${model.src} -> ${cachePath}/${modelName}" ant.get(src: model.src, dest: file("${cachePath}/${modelName}")) } copyFiles = true } if (copyFiles) { 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 "[INFO] Downloading and extracting fastdeploy android java sdk ..." } doLast { String cachePath = "cache" if (!file("${cachePath}").exists()) { mkdir("${cachePath}") } FD_JAVA_SDK.eachWithIndex { sdk, index -> String[] sdkPaths = sdk.src.split("/") String cacheName = sdkPaths[sdkPaths.length - 1] String sdkName = sdk.name boolean copyFiles = false if (!file("${sdk.dest}/${sdkName}").exists()) { // Download the target SDK if not exists if (!file("${cachePath}/${cacheName}").exists()) { println "[INFO] Downloading ${sdk.src} -> ${cachePath}/${cacheName}" ant.get(src: sdk.src, dest: file("${cachePath}/${cacheName}")) } copyFiles = true } if (copyFiles) { println "[INFO] Rename ${cachePath}/${cacheName} -> ${sdk.dest}/${sdkName}" copy { from("${cachePath}/${cacheName}") into("${sdk.dest}") rename("${cacheName}", "${sdkName}") } } else { println "[INFO] ${sdk.dest}/${sdkName} already exists!" } } } } preBuild.dependsOn downloadAndExtractSDKs preBuild.dependsOn downloadAndExtractModels