diff --git a/FastDeploy.cmake.in b/FastDeploy.cmake.in index 1074c86ad..92439af61 100755 --- a/FastDeploy.cmake.in +++ b/FastDeploy.cmake.in @@ -18,8 +18,6 @@ set(PADDLEINFERENCE_VERSION @PADDLEINFERENCE_VERSION@) set(OPENVINO_VERSION @OPENVINO_VERSION@) set(WITH_LITE_STATIC @WITH_LITE_STATIC@) set(WITH_OPENCV_STATIC @WITH_OPENCV_STATIC@) -set(WITH_LITE_FULL_API @WITH_LITE_FULL_API@) -set(WITH_LITE_FP16 @WITH_LITE_FP16@) # set(ENABLE_OPENCV_CUDA @ENABLE_OPENCV_CUDA@) set(OPENCV_FILENAME @OPENCV_FILENAME@) set(OPENVINO_FILENAME @OPENVINO_FILENAME@) @@ -106,15 +104,9 @@ if(ENABLE_LITE_BACKEND) set(LITE_DIR ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/${PADDLELITE_FILENAME}) if(ANDROID) if(NOT WITH_LITE_STATIC) - if(WITH_LITE_FULL_API) - add_library(paddle_full_api_shared STATIC IMPORTED GLOBAL) - set_property(TARGET paddle_full_api_shared PROPERTY IMPORTED_LOCATION ${LITE_DIR}/lib/${ANDROID_ABI}/libpaddle_full_api_shared.so) - list(APPEND FASTDEPLOY_LIBS paddle_full_api_shared) - else() - add_library(paddle_light_api_shared STATIC IMPORTED GLOBAL) - set_property(TARGET paddle_light_api_shared PROPERTY IMPORTED_LOCATION ${LITE_DIR}/lib/${ANDROID_ABI}/libpaddle_light_api_shared.so) - list(APPEND FASTDEPLOY_LIBS paddle_light_api_shared) - endif() + add_library(paddle_full_api_shared STATIC IMPORTED GLOBAL) + set_property(TARGET paddle_full_api_shared PROPERTY IMPORTED_LOCATION ${LITE_DIR}/lib/${ANDROID_ABI}/libpaddle_full_api_shared.so) + list(APPEND FASTDEPLOY_LIBS paddle_full_api_shared) endif() else() # Linux/Mac/Win/... @@ -285,8 +277,6 @@ if(ANDROID) message(STATUS " WITH_OPENCV_STATIC: : ${WITH_OPENCV_STATIC}") if(ENABLE_LITE_BACKEND) message(STATUS " WITH_LITE_STATIC : ${WITH_LITE_STATIC}") - message(STATUS " WITH_LITE_FULL_API : ${WITH_LITE_FULL_API}") - message(STATUS " WITH_LITE_FP16 : ${WITH_LITE_FP16}") endif() endif() message(STATUS " DEPENDENCY_LIBS : ${FASTDEPLOY_LIBS}") diff --git a/cmake/summary.cmake b/cmake/summary.cmake index 9a545441f..7a729484e 100755 --- a/cmake/summary.cmake +++ b/cmake/summary.cmake @@ -33,6 +33,7 @@ function(fastdeploy_summary) message(STATUS " ENABLE_ORT_BACKEND : ${ENABLE_ORT_BACKEND}") message(STATUS " ENABLE_RKNPU2_BACKEND : ${ENABLE_RKNPU2_BACKEND}") message(STATUS " ENABLE_PADDLE_BACKEND : ${ENABLE_PADDLE_BACKEND}") + message(STATUS " ENABLE_LITE_BACKEND : ${ENABLE_LITE_BACKEND}") message(STATUS " ENABLE_POROS_BACKEND : ${ENABLE_POROS_BACKEND}") message(STATUS " ENABLE_TRT_BACKEND : ${ENABLE_TRT_BACKEND}") message(STATUS " ENABLE_OPENVINO_BACKEND : ${ENABLE_OPENVINO_BACKEND}") diff --git a/fastdeploy/vision/classification/ppcls/model.cc b/fastdeploy/vision/classification/ppcls/model.cc index 94ee0e119..935336a26 100644 --- a/fastdeploy/vision/classification/ppcls/model.cc +++ b/fastdeploy/vision/classification/ppcls/model.cc @@ -72,7 +72,6 @@ bool PaddleClasModel::BatchPredict(const std::vector& images, std::vect FDERROR << "Failed to preprocess the input image." << std::endl; return false; } - reused_input_tensors_[0].name = InputInfoOfRuntime(0).name; if (!Infer(reused_input_tensors_, &reused_output_tensors_)) { FDERROR << "Failed to inference by runtime." << std::endl; diff --git a/fastdeploy/vision/common/processors/base.h b/fastdeploy/vision/common/processors/base.h index c833ef8a3..00bd9c82f 100644 --- a/fastdeploy/vision/common/processors/base.h +++ b/fastdeploy/vision/common/processors/base.h @@ -32,8 +32,7 @@ FASTDEPLOY_DECL void EnableFlyCV(); /// Disable using FlyCV to process image while deploy vision models. FASTDEPLOY_DECL void DisableFlyCV(); -/*! @brief Set the cpu num threads of ProcLib. The cpu num threads - * of FlyCV and OpenCV is 2 by default. +/*! @brief Set the cpu num threads of ProcLib. */ FASTDEPLOY_DECL void SetProcLibCpuNumThreads(int threads); diff --git a/fastdeploy/vision/common/processors/color_space_convert.cc b/fastdeploy/vision/common/processors/color_space_convert.cc index c486c5379..5d2158063 100644 --- a/fastdeploy/vision/common/processors/color_space_convert.cc +++ b/fastdeploy/vision/common/processors/color_space_convert.cc @@ -72,8 +72,8 @@ bool BGR2GRAY::ImplByOpenCV(FDMat* mat) { } #ifdef ENABLE_FLYCV -bool BGR2GRAY::ImplByFalconCV(FDMat* mat) { - fcv::Mat* im = mat->GetFalconCVMat(); +bool BGR2GRAY::ImplByFlyCV(FDMat* mat) { + fcv::Mat* im = mat->GetFlyCVMat(); if (im->channels() != 3) { FDERROR << "[BGR2GRAY] The channel of input image must be 3, but not it's " << im->channels() << "." << std::endl; return false; @@ -94,8 +94,8 @@ bool RGB2GRAY::ImplByOpenCV(FDMat* mat) { } #ifdef ENABLE_FLYCV -bool RGB2GRAY::ImplByFalconCV(FDMat* mat) { - fcv::Mat* im = mat->GetFalconCVMat(); +bool RGB2GRAY::ImplByFlyCV(FDMat* mat) { + fcv::Mat* im = mat->GetFlyCVMat(); if (im->channels() != 3) { FDERROR << "[RGB2GRAY] The channel of input image must be 3, but not it's " << im->channels() << "." << std::endl; return false; diff --git a/fastdeploy/vision/common/processors/color_space_convert.h b/fastdeploy/vision/common/processors/color_space_convert.h index f9cb10a19..490034868 100644 --- a/fastdeploy/vision/common/processors/color_space_convert.h +++ b/fastdeploy/vision/common/processors/color_space_convert.h @@ -45,22 +45,22 @@ class FASTDEPLOY_DECL BGR2GRAY : public Processor { public: bool ImplByOpenCV(FDMat* mat); #ifdef ENABLE_FLYCV - bool ImplByFalconCV(FDMat* mat); + bool ImplByFlyCV(FDMat* mat); #endif virtual std::string Name() { return "BGR2GRAY"; } - static bool Run(FDMat* mat, ProcLib lib = ProcLib::OPENCV); + static bool Run(FDMat* mat, ProcLib lib = ProcLib::DEFAULT); }; class FASTDEPLOY_DECL RGB2GRAY : public Processor { public: bool ImplByOpenCV(FDMat* mat); #ifdef ENABLE_FLYCV - bool ImplByFalconCV(FDMat* mat); + bool ImplByFlyCV(FDMat* mat); #endif std::string Name() { return "RGB2GRAY"; } - static bool Run(FDMat* mat, ProcLib lib = ProcLib::OPENCV); + static bool Run(FDMat* mat, ProcLib lib = ProcLib::DEFAULT); }; diff --git a/fastdeploy/vision/facedet/contrib/scrfd.cc b/fastdeploy/vision/facedet/contrib/scrfd.cc index dcb590b82..257db57b3 100644 --- a/fastdeploy/vision/facedet/contrib/scrfd.cc +++ b/fastdeploy/vision/facedet/contrib/scrfd.cc @@ -153,7 +153,7 @@ bool SCRFD::Preprocess(Mat* mat, FDTensor* output, HWC2CHW::Run(mat); Cast::Run(mat, "float"); } - + // Record output shape of preprocessed image (*im_info)["output_shape"] = {static_cast(mat->Height()), static_cast(mat->Width())}; diff --git a/fastdeploy/vision/facedet/contrib/yolov5face.cc b/fastdeploy/vision/facedet/contrib/yolov5face.cc index ed507363e..094ab577b 100644 --- a/fastdeploy/vision/facedet/contrib/yolov5face.cc +++ b/fastdeploy/vision/facedet/contrib/yolov5face.cc @@ -149,6 +149,7 @@ bool YOLOv5Face::Preprocess( HWC2CHW::Run(mat); Cast::Run(mat, "float"); + mat->ShareWithTensor(output); output->shape.insert(output->shape.begin(), 1); // reshape to n, h, w, c return true; diff --git a/java/android/app/src/main/AndroidManifest.xml b/java/android/app/src/main/AndroidManifest.xml index 316b35c03..aaad8ac85 100644 --- a/java/android/app/src/main/AndroidManifest.xml +++ b/java/android/app/src/main/AndroidManifest.xml @@ -15,14 +15,14 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + diff --git a/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/classification/ClassificationMainActivity.java b/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/classification/ClassificationMainActivity.java index c78f8f397..14c1c329f 100644 --- a/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/classification/ClassificationMainActivity.java +++ b/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/classification/ClassificationMainActivity.java @@ -77,8 +77,8 @@ public class ClassificationMainActivity extends Activity implements View.OnClick private static final int INTENT_CODE_PICK_IMAGE = 100; String savedImagePath = "result.jpg"; - int lastFrameIndex = 0; - long lastFrameTime; + long timeElapsed = 0; + long frameCounter = 0; // Call 'init' and 'release' manually later PaddleClasModel predictor = new PaddleClasModel(); @@ -203,25 +203,31 @@ public class ClassificationMainActivity extends Activity implements View.OnClick originShutterBitmap = ARGB8888ImageBitmap; } boolean modified = false; + + long tc = System.currentTimeMillis(); ClassifyResult result = predictor.predict( ARGB8888ImageBitmap, true, ClassificationSettingsActivity.scoreThreshold); + + timeElapsed += (System.currentTimeMillis() - tc); + frameCounter++; + modified = result.initialized(); if (!savedImagePath.isEmpty()) { synchronized (this) { ClassificationMainActivity.this.savedImagePath = "result.jpg"; } } - lastFrameIndex++; - if (lastFrameIndex >= 30) { - final int fps = (int) (lastFrameIndex * 1e9 / (System.nanoTime() - lastFrameTime)); + + if (frameCounter >= 30) { + final int fps = (int) (1000 / (timeElapsed / 30)); runOnUiThread(new Runnable() { @SuppressLint("SetTextI18n") public void run() { tvStatus.setText(Integer.toString(fps) + "fps"); } }); - lastFrameIndex = 0; - lastFrameTime = System.nanoTime(); + frameCounter = 0; + timeElapsed = 0; } return modified; } diff --git a/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/detection/DetectionMainActivity.java b/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/detection/DetectionMainActivity.java index 2b654e8a8..e890b42f0 100644 --- a/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/detection/DetectionMainActivity.java +++ b/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/detection/DetectionMainActivity.java @@ -84,8 +84,8 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe private static final int TIME_SLEEP_INTERVAL = 50; // ms String savedImagePath = "result.jpg"; - int lastFrameIndex = 0; - long lastFrameTime; + long timeElapsed = 0; + long frameCounter = 0; // Call 'init' and 'release' manually later PicoDet predictor = new PicoDet(); @@ -159,7 +159,7 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe public void run() { try { // Sleep some times to ensure picture has been correctly shut. - Thread.sleep(TIME_SLEEP_INTERVAL * 2); // 100ms + Thread.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms } catch (InterruptedException e) { e.printStackTrace(); } @@ -251,25 +251,30 @@ public class DetectionMainActivity extends Activity implements View.OnClickListe } boolean modified = false; + + long tc = System.currentTimeMillis(); DetectionResult result = predictor.predict( ARGB8888ImageBitmap, true, DetectionSettingsActivity.scoreThreshold); + timeElapsed += (System.currentTimeMillis() - tc); + frameCounter++; + modified = result.initialized(); if (!savedImagePath.isEmpty()) { synchronized (this) { DetectionMainActivity.this.savedImagePath = "result.jpg"; } } - lastFrameIndex++; - if (lastFrameIndex >= 30) { - final int fps = (int) (lastFrameIndex * 1e9 / (System.nanoTime() - lastFrameTime)); + + if (frameCounter >= 30) { + final int fps = (int) (1000 / (timeElapsed / 30)); runOnUiThread(new Runnable() { @SuppressLint("SetTextI18n") public void run() { tvStatus.setText(Integer.toString(fps) + "fps"); } }); - lastFrameIndex = 0; - lastFrameTime = System.nanoTime(); + frameCounter = 0; + timeElapsed = 0; } return modified; } diff --git a/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/facedet/FaceDetMainActivity.java b/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/facedet/FaceDetMainActivity.java index a5b5aa839..56cc8e815 100644 --- a/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/facedet/FaceDetMainActivity.java +++ b/java/android/app/src/main/java/com/baidu/paddle/fastdeploy/app/examples/facedet/FaceDetMainActivity.java @@ -36,7 +36,6 @@ import com.baidu.paddle.fastdeploy.app.ui.view.ResultListView; import com.baidu.paddle.fastdeploy.app.ui.Utils; import com.baidu.paddle.fastdeploy.app.ui.view.adapter.BaseResultAdapter; import com.baidu.paddle.fastdeploy.app.ui.view.model.BaseResultModel; -import com.baidu.paddle.fastdeploy.vision.DetectionResult; import com.baidu.paddle.fastdeploy.vision.FaceDetectionResult; import com.baidu.paddle.fastdeploy.vision.facedet.SCRFD; @@ -84,8 +83,8 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene private static final int TIME_SLEEP_INTERVAL = 50; // ms String savedImagePath = "result.jpg"; - int lastFrameIndex = 0; - long lastFrameTime; + long timeElapsed = 0; + long frameCounter = 0; // Call 'init' and 'release' manually later SCRFD predictor = new SCRFD(); @@ -159,7 +158,7 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene public void run() { try { // Sleep some times to ensure picture has been correctly shut. - Thread.sleep(TIME_SLEEP_INTERVAL * 2); // 100ms + Thread.sleep(TIME_SLEEP_INTERVAL * 10); // 500ms } catch (InterruptedException e) { e.printStackTrace(); } @@ -251,25 +250,31 @@ public class FaceDetMainActivity extends Activity implements View.OnClickListene } boolean modified = false; + + long tc = System.currentTimeMillis(); FaceDetectionResult result = predictor.predict( ARGB8888ImageBitmap, true, FaceDetSettingsActivity.scoreThreshold, 0.4f); + + timeElapsed += (System.currentTimeMillis() - tc); + frameCounter++; + modified = result.initialized(); if (!savedImagePath.isEmpty()) { synchronized (this) { FaceDetMainActivity.this.savedImagePath = "result.jpg"; } } - lastFrameIndex++; - if (lastFrameIndex >= 30) { - final int fps = (int) (lastFrameIndex * 1e9 / (System.nanoTime() - lastFrameTime)); + + if (frameCounter >= 30) { + final int fps = (int) (1000 / (timeElapsed / 30)); runOnUiThread(new Runnable() { @SuppressLint("SetTextI18n") public void run() { tvStatus.setText(Integer.toString(fps) + "fps"); } }); - lastFrameIndex = 0; - lastFrameTime = System.nanoTime(); + frameCounter = 0; + timeElapsed = 0; } return modified; }