diff --git a/deploy/android_demo/app/build.gradle b/deploy/android_demo/app/build.gradle index 5ecb11692c2a66f941dc41425761519607bad39e..494247a3792814ab8373f150c5f7b35b1b821971 100644 --- a/deploy/android_demo/app/build.gradle +++ b/deploy/android_demo/app/build.gradle @@ -57,7 +57,7 @@ def archives = [ ], [ 'src' : 'https://paddleocr.bj.bcebos.com/deploy/lite/ocr_v1_for_cpu.tar.gz', - 'dest' : 'src/main/assets/models/ocr_v1_for_cpu' + 'dest' : 'src/main/assets/models' ] ] diff --git a/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/OCRPredictorNative.java b/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/OCRPredictorNative.java index 3bb7e06d2f33a0ed8bf08e7edc8b1866ac564ce6..1fa419e32a4cbefc27fc687b376ecc7e6a1e8a2f 100644 --- a/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/OCRPredictorNative.java +++ b/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/OCRPredictorNative.java @@ -53,11 +53,18 @@ public class OCRPredictorNative { } + public void destory(){ + if (nativePointer > 0) { + release(nativePointer); + nativePointer = 0; + } + } + protected native long init(String detModelPath, String recModelPath,String clsModelPath, int threadNum, String cpuMode); protected native float[] forward(long pointer, float[] buf, float[] ddims, Bitmap originalImage); - public native void release(long pointer); + protected native void release(long pointer); private ArrayList postprocess(float[] raw) { ArrayList results = new ArrayList(); diff --git a/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/Predictor.java b/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/Predictor.java index ddf69ab481618696189a7d0d45264791267e5631..572d0b22deada648d1291091d05130d5ecf270a8 100644 --- a/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/Predictor.java +++ b/deploy/android_demo/app/src/main/java/com/baidu/paddle/lite/demo/ocr/Predictor.java @@ -135,7 +135,7 @@ public class Predictor { public void releaseModel() { if (paddlePredictor != null) { - paddlePredictor.release(); + paddlePredictor.destory(); paddlePredictor = null; } isLoaded = false;