diff --git a/.circleci/scripts/linux/build.sh b/.circleci/scripts/linux/build.sh index 77342f9dd2..fc7827d0a9 100644 --- a/.circleci/scripts/linux/build.sh +++ b/.circleci/scripts/linux/build.sh @@ -6,7 +6,7 @@ cd mmdeploy MMDEPLOY_DIR=$(pwd) mkdir -p build && cd build cmake .. -DMMDEPLOY_BUILD_SDK=ON -DMMDEPLOY_BUILD_TEST=ON -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON \ - -DMMDEPLOY_BUILD_EXAMPLES=ON -DMMDEPLOY_BUILD_SDK_CXX_API=ON -DMMDEPLOY_BUILD_SDK_CSHARP_API=ON \ + -DMMDEPLOY_BUILD_EXAMPLES=ON -DMMDEPLOY_BUILD_SDK_CSHARP_API=ON \ -DMMDEPLOY_TARGET_DEVICES="$1" -DMMDEPLOY_TARGET_BACKENDS="$2" "${ARGS[@]:2}" make -j$(nproc) && make install diff --git a/.circleci/test.yml b/.circleci/test.yml index 4aa1e4f951..9e1b5ee264 100644 --- a/.circleci/test.yml +++ b/.circleci/test.yml @@ -217,7 +217,6 @@ jobs: -DMMDEPLOY_BUILD_TEST=ON ` -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON ` -DMMDEPLOY_BUILD_EXAMPLES=ON ` - -DMMDEPLOY_BUILD_SDK_CXX_API=ON ` -DMMDEPLOY_BUILD_SDK_CSHARP_API=ON ` -DMMDEPLOY_TARGET_BACKENDS="ort" ` -DOpenCV_DIR="$env:OPENCV_PACKAGE_DIR" diff --git a/CMakeLists.txt b/CMakeLists.txt index 839681a7d0..75f9aa5147 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,6 @@ option(MMDEPLOY_BUILD_SDK "build MMDeploy SDK" OFF) option(MMDEPLOY_BUILD_SDK_MONOLITHIC "build single lib for SDK API" ON) option(MMDEPLOY_BUILD_TEST "build unittests" OFF) option(MMDEPLOY_BUILD_SDK_PYTHON_API "build SDK Python API" OFF) -option(MMDEPLOY_BUILD_SDK_CXX_API "build SDK C++ API" OFF) option(MMDEPLOY_BUILD_SDK_CSHARP_API "build SDK C# API support" OFF) option(MMDEPLOY_BUILD_SDK_JAVA_API "build SDK JAVA API" OFF) option(MMDEPLOY_BUILD_EXAMPLES "build examples" OFF) @@ -106,7 +105,8 @@ if (MMDEPLOY_BUILD_SDK) if (MMDEPLOY_BUILD_EXAMPLES) include(${CMAKE_SOURCE_DIR}/cmake/opencv.cmake) - add_subdirectory(demo/csrc) + add_subdirectory(demo/c) + add_subdirectory(demo/cpp) endif () # export MMDeploy package @@ -117,16 +117,18 @@ if (MMDEPLOY_BUILD_SDK) if (MMDEPLOY_SPDLOG_EXTERNAL) set(SPDLOG_DEPENDENCY "find_package(spdlog QUIET)") endif () - # append backend deps - mmdeploy_add_deps(trt BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS TENSORRT CUDNN) - mmdeploy_add_deps(ort BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS ONNXRUNTIME) - mmdeploy_add_deps(ncnn BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS ncnn) - mmdeploy_add_deps(openvino BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS InferenceEngine) - if (NOT MMDEPLOY_SHARED_LIBS) - mmdeploy_add_deps(pplnn BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS pplnn) + if (NOT MMDEPLOY_BUILD_SDK_MONOLITHIC) + # append backend deps + mmdeploy_add_deps(trt BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS TENSORRT CUDNN) + mmdeploy_add_deps(ort BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS ONNXRUNTIME) + mmdeploy_add_deps(ncnn BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS ncnn) + mmdeploy_add_deps(openvino BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS InferenceEngine) + if (NOT MMDEPLOY_SHARED_LIBS) + mmdeploy_add_deps(pplnn BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS pplnn) + endif () + mmdeploy_add_deps(snpe BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS snpe) + mmdeploy_add_deps(rknn BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS rknn) endif () - mmdeploy_add_deps(snpe BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS snpe) - mmdeploy_add_deps(rknn BACKENDS ${MMDEPLOY_TARGET_BACKENDS} DEPS rknn) include(CMakePackageConfigHelpers) # generate the config file that is includes the exports diff --git a/cmake/MMDeployConfig.cmake.in b/cmake/MMDeployConfig.cmake.in index 23e728f7ab..fd3679791f 100644 --- a/cmake/MMDeployConfig.cmake.in +++ b/cmake/MMDeployConfig.cmake.in @@ -10,13 +10,12 @@ set(MMDEPLOY_TARGET_DEVICES @MMDEPLOY_TARGET_DEVICES@) set(MMDEPLOY_TARGET_BACKENDS @MMDEPLOY_TARGET_BACKENDS@) set(MMDEPLOY_BUILD_TYPE @CMAKE_BUILD_TYPE@) set(MMDEPLOY_BUILD_SHARED @MMDEPLOY_SHARED_LIBS@) -set(MMDEPLOY_BUILD_SDK_CXX_API @MMDEPLOY_BUILD_SDK_CXX_API@) set(MMDEPLOY_BUILD_SDK_MONOLITHIC @MMDEPLOY_BUILD_SDK_MONOLITHIC@) set(MMDEPLOY_VERSION_MAJOR @MMDEPLOY_VERSION_MAJOR@) set(MMDEPLOY_VERSION_MINOR @MMDEPLOY_VERSION_MINOR@) set(MMDEPLOY_VERSION_PATCH @MMDEPLOY_VERSION_PATCH@) -if (NOT MMDEPLOY_BUILD_SHARED) +if (NOT MMDEPLOY_BUILD_SHARED AND NOT MMDEPLOY_BUILD_SDK_MONOLITHIC) if ("cuda" IN_LIST MMDEPLOY_TARGET_DEVICES) find_package(CUDA REQUIRED) if(MSVC) diff --git a/cmake/modules/FindCUDNN.cmake b/cmake/modules/FindCUDNN.cmake index 3f3f9b893a..6a4ceb593e 100644 --- a/cmake/modules/FindCUDNN.cmake +++ b/cmake/modules/FindCUDNN.cmake @@ -1,5 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. +if (TARGET cudnn) + return() +endif () + if (NOT DEFINED CUDNN_DIR) set(CUDNN_DIR $ENV{CUDNN_DIR}) endif () diff --git a/cmake/modules/FindONNXRUNTIME.cmake b/cmake/modules/FindONNXRUNTIME.cmake index 63ea176595..2e8ba66528 100644 --- a/cmake/modules/FindONNXRUNTIME.cmake +++ b/cmake/modules/FindONNXRUNTIME.cmake @@ -1,5 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. - +if (TARGET onnxruntime) + return () +endif () if (NOT DEFINED ONNXRUNTIME_DIR) set(ONNXRUNTIME_DIR $ENV{ONNXRUNTIME_DIR}) endif () diff --git a/cmake/modules/FindTENSORRT.cmake b/cmake/modules/FindTENSORRT.cmake index e2c328923e..e7be358c3d 100644 --- a/cmake/modules/FindTENSORRT.cmake +++ b/cmake/modules/FindTENSORRT.cmake @@ -1,5 +1,9 @@ # Copyright (c) OpenMMLab. All rights reserved. +if (TARGET nvinfer) + return () +endif () + if (NOT DEFINED TENSORRT_DIR) set(TENSORRT_DIR $ENV{TENSORRT_DIR}) endif () diff --git a/cmake/modules/FindTVM.cmake b/cmake/modules/FindTVM.cmake index f6443609e4..f5284d82e5 100644 --- a/cmake/modules/FindTVM.cmake +++ b/cmake/modules/FindTVM.cmake @@ -1,4 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. +if (TARGET tvm_runtime) + return() +endif () if (NOT DEFINED TVM_DIR) set(TVM_DIR $ENV{TVM_DIR}) diff --git a/csrc/mmdeploy/apis/CMakeLists.txt b/csrc/mmdeploy/apis/CMakeLists.txt index deb9831fc3..1ab877be90 100644 --- a/csrc/mmdeploy/apis/CMakeLists.txt +++ b/csrc/mmdeploy/apis/CMakeLists.txt @@ -1,10 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. -# Python API depends on C++ API -if (MMDEPLOY_BUILD_SDK_PYTHON_API) - set(MMDEPLOY_BUILD_SDK_CXX_API ON) -endif () - add_subdirectory(c) add_subdirectory(cxx) add_subdirectory(java) diff --git a/csrc/mmdeploy/apis/c/CMakeLists.txt b/csrc/mmdeploy/apis/c/CMakeLists.txt index a9dd03c06a..faeb12a7cf 100644 --- a/csrc/mmdeploy/apis/c/CMakeLists.txt +++ b/csrc/mmdeploy/apis/c/CMakeLists.txt @@ -55,11 +55,7 @@ foreach (TASK ${TASK_LIST}) DESTINATION include/mmdeploy) endforeach () -install(DIRECTORY ${CMAKE_SOURCE_DIR}/demo/csrc/ DESTINATION example/cpp - FILES_MATCHING - PATTERN "*.cpp" - PATTERN "CMakeLists.txt" - ) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/demo/c/ DESTINATION example/c) if (MMDEPLOY_BUILD_SDK_CSHARP_API OR MMDEPLOY_BUILD_SDK_MONOLITHIC) add_library(mmdeploy SHARED) diff --git a/csrc/mmdeploy/apis/cxx/CMakeLists.txt b/csrc/mmdeploy/apis/cxx/CMakeLists.txt index 7f0a646265..f29dc2889e 100644 --- a/csrc/mmdeploy/apis/cxx/CMakeLists.txt +++ b/csrc/mmdeploy/apis/cxx/CMakeLists.txt @@ -3,27 +3,22 @@ cmake_minimum_required(VERSION 3.14) project(mmdeploy_cxx_api) -if (MMDEPLOY_BUILD_SDK_CXX_API) - add_library(${PROJECT_NAME} INTERFACE) - target_include_directories(${PROJECT_NAME} INTERFACE - $ - $) - target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17) - target_link_libraries(${PROJECT_NAME} INTERFACE mmdeploy::core) - set(_tasks ${MMDEPLOY_TASKS} pipeline) - foreach (task ${_tasks}) - target_link_libraries(mmdeploy_${task} INTERFACE ${PROJECT_NAME}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mmdeploy/${task}.hpp - DESTINATION include/mmdeploy) - endforeach () - if (TARGET mmdeploy) - target_link_libraries(mmdeploy INTERFACE ${PROJECT_NAME}) - endif () - mmdeploy_export(${PROJECT_NAME}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mmdeploy/common.hpp +add_library(${PROJECT_NAME} INTERFACE) +target_include_directories(${PROJECT_NAME} INTERFACE + $ + $) +target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17) +target_link_libraries(${PROJECT_NAME} INTERFACE mmdeploy::core) +set(_tasks ${MMDEPLOY_TASKS} pipeline) +foreach (task ${_tasks}) + target_link_libraries(mmdeploy_${task} INTERFACE ${PROJECT_NAME}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mmdeploy/${task}.hpp DESTINATION include/mmdeploy) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/demo/csrc/ DESTINATION example/cpp - FILES_MATCHING - PATTERN "*.cxx" - ) +endforeach () +if (TARGET mmdeploy) + target_link_libraries(mmdeploy INTERFACE ${PROJECT_NAME}) endif () +mmdeploy_export(${PROJECT_NAME}) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mmdeploy/common.hpp + DESTINATION include/mmdeploy) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/demo/cpp/ DESTINATION example/cpp) diff --git a/csrc/mmdeploy/archive/CMakeLists.txt b/csrc/mmdeploy/archive/CMakeLists.txt index 21bb3ae59d..3f3d1f1104 100644 --- a/csrc/mmdeploy/archive/CMakeLists.txt +++ b/csrc/mmdeploy/archive/CMakeLists.txt @@ -6,10 +6,8 @@ add_library(${PROJECT_NAME} INTERFACE) target_link_libraries(${PROJECT_NAME} INTERFACE mmdeploy::core) add_library(mmdeploy::archive ALIAS mmdeploy_archive) -if (MMDEPLOY_BUILD_SDK_CXX_API) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/csrc/mmdeploy/archive - DESTINATION include/mmdeploy - FILES_MATCHING PATTERN "*.h") - install(FILES ${CMAKE_SOURCE_DIR}/third_party/json/json.hpp - DESTINATION include/mmdeploy/third_party/json) -endif () +install(DIRECTORY ${CMAKE_SOURCE_DIR}/csrc/mmdeploy/archive + DESTINATION include/mmdeploy + FILES_MATCHING PATTERN "*.h") +install(FILES ${CMAKE_SOURCE_DIR}/third_party/json/json.hpp + DESTINATION include/mmdeploy/third_party/json) diff --git a/csrc/mmdeploy/core/CMakeLists.txt b/csrc/mmdeploy/core/CMakeLists.txt index 33d0f76c57..4516f304cd 100644 --- a/csrc/mmdeploy/core/CMakeLists.txt +++ b/csrc/mmdeploy/core/CMakeLists.txt @@ -19,10 +19,8 @@ else () endif () set(SPDLOG_LIB spdlog::spdlog) mmdeploy_export(spdlog) - if (MMDEPLOY_BUILD_SDK_CXX_API) - install(DIRECTORY ${MMDEPLOY_SPDLOG_DIR}/include/spdlog - DESTINATION include/mmdeploy/third_party) - endif () + install(DIRECTORY ${MMDEPLOY_SPDLOG_DIR}/include/spdlog + DESTINATION include/mmdeploy/third_party) endif () set(SRCS @@ -65,15 +63,13 @@ else () target_compile_definitions(${PROJECT_NAME} PUBLIC -DMMDEPLOY_STATUS_USE_SOURCE_LOCATION=1) endif () -if (MMDEPLOY_BUILD_SDK_CXX_API) - target_include_directories(${PROJECT_NAME} PUBLIC - $ - $ - $) - if (NOT MMDEPLOY_SPDLOG_EXTERNAL) - target_include_directories(spdlog INTERFACE - $) - endif () +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ + $) +if (NOT MMDEPLOY_SPDLOG_EXTERNAL) + target_include_directories(spdlog INTERFACE + $) endif () target_link_libraries(${PROJECT_NAME} PUBLIC ${SPDLOG_LIB}) @@ -85,14 +81,12 @@ endif () add_library(mmdeploy::core ALIAS ${PROJECT_NAME}) -if (MMDEPLOY_BUILD_SDK_CXX_API) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/csrc/mmdeploy/core - DESTINATION include/mmdeploy - FILES_MATCHING PATTERN "*.h") - install(FILES ${CMAKE_SOURCE_DIR}/third_party/outcome/outcome-experimental.hpp - DESTINATION include/mmdeploy/third_party/outcome) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/csrc/mmdeploy/core + DESTINATION include/mmdeploy + FILES_MATCHING PATTERN "*.h") +install(FILES ${CMAKE_SOURCE_DIR}/third_party/outcome/outcome-experimental.hpp + DESTINATION include/mmdeploy/third_party/outcome) - install(DIRECTORY ${CMAKE_SOURCE_DIR}/csrc/mmdeploy/experimental - DESTINATION include/mmdeploy - FILES_MATCHING PATTERN "*.h") -endif () +install(DIRECTORY ${CMAKE_SOURCE_DIR}/csrc/mmdeploy/experimental + DESTINATION include/mmdeploy + FILES_MATCHING PATTERN "*.h") diff --git a/demo/c/CMakeLists.txt b/demo/c/CMakeLists.txt new file mode 100644 index 0000000000..aaf3437c88 --- /dev/null +++ b/demo/c/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_capi_demo) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +set(TASK_LIST ${MMDEPLOY_TASKS}) + +if ("text_detector" IN_LIST TASK_LIST OR "text_recognizer" IN_LIST TASK_LIST) + list(REMOVE_ITEM TASK_LIST "text_detector" "text_recognizer") + add_subdirectory(ocr) +endif() + +foreach(TASK ${TASK_LIST}) + add_subdirectory(${TASK}) +endforeach() diff --git a/demo/c/classifier/CMakeLists.txt b/demo/c/classifier/CMakeLists.txt new file mode 100644 index 0000000000..37fbb0b5d0 --- /dev/null +++ b/demo/c/classifier/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_capi_classifier) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +macro(link_mmdeploy target_name) + if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(${target_name} PRIVATE -Wl,--disable-new-dtags) + endif () + if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(${target_name} PRIVATE mmdeploy ${OpenCV_LIBS}) + else () + # Load MMDeploy modules + mmdeploy_load_static(${target_name} MMDeployStaticModules) + mmdeploy_load_dynamic(${target_name} MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(${target_name} PRIVATE MMDeployLibs ${OpenCV_LIBS}) + endif () +endmacro() + +add_executable(image_classification main.cpp) +add_executable(batch_image_classification batch.cpp) + +link_mmdeploy(image_classification) +link_mmdeploy(batch_image_classification) diff --git a/demo/csrc/c/batch_image_classification.cpp b/demo/c/classifier/batch.cpp similarity index 100% rename from demo/csrc/c/batch_image_classification.cpp rename to demo/c/classifier/batch.cpp diff --git a/demo/csrc/c/image_classification.cpp b/demo/c/classifier/main.cpp similarity index 96% rename from demo/csrc/c/image_classification.cpp rename to demo/c/classifier/main.cpp index 5e64581b9f..19a1a634a1 100644 --- a/demo/csrc/c/image_classification.cpp +++ b/demo/c/classifier/main.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include "mmdeploy/classifier.h" diff --git a/demo/c/detector/CMakeLists.txt b/demo/c/detector/CMakeLists.txt new file mode 100644 index 0000000000..404fd7e720 --- /dev/null +++ b/demo/c/detector/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_capi_detector) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +macro(link_mmdeploy target_name) + if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(${target_name} PRIVATE -Wl,--disable-new-dtags) + endif () + if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(${target_name} PRIVATE mmdeploy ${OpenCV_LIBS}) + else () + # Load MMDeploy modules + mmdeploy_load_static(${target_name} MMDeployStaticModules) + mmdeploy_load_dynamic(${target_name} MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(${target_name} PRIVATE MMDeployLibs ${OpenCV_LIBS}) + endif () +endmacro() + +add_executable(object_detection main.cpp) +add_executable(batch_object_detection batch.cpp) + +link_mmdeploy(object_detection) +link_mmdeploy(batch_object_detection) diff --git a/demo/csrc/c/batch_object_detection.cpp b/demo/c/detector/batch.cpp similarity index 100% rename from demo/csrc/c/batch_object_detection.cpp rename to demo/c/detector/batch.cpp diff --git a/demo/csrc/c/object_detection.cpp b/demo/c/detector/main.cpp similarity index 100% rename from demo/csrc/c/object_detection.cpp rename to demo/c/detector/main.cpp diff --git a/demo/c/ocr/CMakeLists.txt b/demo/c/ocr/CMakeLists.txt new file mode 100644 index 0000000000..7c9f824237 --- /dev/null +++ b/demo/c/ocr/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_capi_ocr) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(image_ocr main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(image_ocr PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(image_ocr PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(image_ocr MMDeployStaticModules) + mmdeploy_load_dynamic(image_ocr MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(image_ocr PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/c/ocr.cpp b/demo/c/ocr/main.cpp similarity index 100% rename from demo/csrc/c/ocr.cpp rename to demo/c/ocr/main.cpp diff --git a/demo/c/pose_detector/CMakeLists.txt b/demo/c/pose_detector/CMakeLists.txt new file mode 100644 index 0000000000..dbc94f3f43 --- /dev/null +++ b/demo/c/pose_detector/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_capi_ocr) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(pose_detection main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(pose_detection PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(pose_detection PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(pose_detection MMDeployStaticModules) + mmdeploy_load_dynamic(pose_detection MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(pose_detection PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/c/pose_detection.cpp b/demo/c/pose_detector/main.cpp similarity index 100% rename from demo/csrc/c/pose_detection.cpp rename to demo/c/pose_detector/main.cpp diff --git a/demo/c/restorer/CMakeLists.txt b/demo/c/restorer/CMakeLists.txt new file mode 100644 index 0000000000..527dbaeac0 --- /dev/null +++ b/demo/c/restorer/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_capi_restorer) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(image_restorer main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(image_restorer PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(image_restorer PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(image_restorer MMDeployStaticModules) + mmdeploy_load_dynamic(image_restorer MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(image_restorer PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/c/image_restorer.cpp b/demo/c/restorer/main.cpp similarity index 100% rename from demo/csrc/c/image_restorer.cpp rename to demo/c/restorer/main.cpp diff --git a/demo/c/rotated_detector/CMakeLists.txt b/demo/c/rotated_detector/CMakeLists.txt new file mode 100644 index 0000000000..13d2ec5ba1 --- /dev/null +++ b/demo/c/rotated_detector/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_capi_rotated_detector) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(rotated_object_detection main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(rotated_object_detection PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(rotated_object_detection PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(rotated_object_detection MMDeployStaticModules) + mmdeploy_load_dynamic(rotated_object_detection MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(rotated_object_detection PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/c/rotated_object_detection.cpp b/demo/c/rotated_detector/main.cpp similarity index 100% rename from demo/csrc/c/rotated_object_detection.cpp rename to demo/c/rotated_detector/main.cpp diff --git a/demo/c/segmentor/CMakeLists.txt b/demo/c/segmentor/CMakeLists.txt new file mode 100644 index 0000000000..110fc7e356 --- /dev/null +++ b/demo/c/segmentor/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_capi_segmentor) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(image_segmentation main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(image_segmentation PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(image_segmentation PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(image_segmentation MMDeployStaticModules) + mmdeploy_load_dynamic(image_segmentation MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(image_segmentation PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/c/image_segmentation.cpp b/demo/c/segmentor/main.cpp similarity index 100% rename from demo/csrc/c/image_segmentation.cpp rename to demo/c/segmentor/main.cpp diff --git a/demo/c/video_recognizer/CMakeLists.txt b/demo/c/video_recognizer/CMakeLists.txt new file mode 100644 index 0000000000..8397430c25 --- /dev/null +++ b/demo/c/video_recognizer/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_video_recognizer) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(video_recognition main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(video_recognition PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(video_recognition PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(video_recognition MMDeployStaticModules) + mmdeploy_load_dynamic(video_recognition MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(video_recognition PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/c/video_recognition.cpp b/demo/c/video_recognizer/main.cpp similarity index 100% rename from demo/csrc/c/video_recognition.cpp rename to demo/c/video_recognizer/main.cpp diff --git a/demo/cpp/CMakeLists.txt b/demo/cpp/CMakeLists.txt new file mode 100644 index 0000000000..ab5ef4b5c8 --- /dev/null +++ b/demo/cpp/CMakeLists.txt @@ -0,0 +1,27 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_demos) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +set(TASK_LIST ${MMDEPLOY_TASKS}) + +if ("text_detector" IN_LIST TASK_LIST OR "text_recognizer" IN_LIST TASK_LIST) + list(REMOVE_ITEM TASK_LIST "text_detector" "text_recognizer") + add_subdirectory(ocr) +endif() + +foreach(TASK ${TASK_LIST}) + add_subdirectory(${TASK}) +endforeach() + +if ("detector" IN_LIST TASK_LIST AND "classifier" IN_LIST TASK_LIST) + add_subdirectory(det_cls) +endif() + +if ("detector" IN_LIST TASK_LIST AND "pose_detector" IN_LIST TASK_LIST) + add_subdirectory(det_pose) + add_subdirectory(pose_tracker) +endif() diff --git a/demo/cpp/classifier/CMakeLists.txt b/demo/cpp/classifier/CMakeLists.txt new file mode 100644 index 0000000000..a17c7c77c3 --- /dev/null +++ b/demo/cpp/classifier/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_classifier) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(classifier main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(classifier PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(classifier PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(classifier MMDeployStaticModules) + mmdeploy_load_dynamic(classifier MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(classifier PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/cpp/classifier/main.cpp b/demo/cpp/classifier/main.cpp new file mode 100644 index 0000000000..6d25b84e80 --- /dev/null +++ b/demo/cpp/classifier/main.cpp @@ -0,0 +1,43 @@ +// Copyright (c) OpenMMLab. All rights reserved. + +#include "mmdeploy/classifier.hpp" + +#include +#include +#include +#include + +int main(int argc, char* argv[]) { + if (argc < 4) { + std::cerr << "usage:" << std::endl + << " ./classifier device_name sdk_model_path image_path" + " [--profile]" + << std::endl; + return 1; + } + auto device_name = argv[1]; + auto model_path = argv[2]; + auto image_path = argv[3]; + auto profile = argc > 4 ? std::string("--profile") == argv[argc - 1] : false; + + mmdeploy::Context context(mmdeploy::Device{device_name}); + mmdeploy::Profiler profiler("profiler.bin"); + if (profile) { + context.Add(profiler); + } + + mmdeploy::Classifier classifier(mmdeploy::Model(model_path), context); + + cv::Mat img = cv::imread(image_path); + if (!img.data) { + std::cerr << "failed to load image: " << image_path; + return 1; + } + auto res = classifier.Apply(img); + + for (const auto& cls : res) { + std::cout << "label: " << cls.label_id << ", score: " << std::fixed << std::setprecision(2) + << cls.score << std::endl; + } + return 0; +} diff --git a/demo/cpp/det_cls/CMakeLists.txt b/demo/cpp/det_cls/CMakeLists.txt new file mode 100644 index 0000000000..3a1004d42e --- /dev/null +++ b/demo/cpp/det_cls/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_det_cls) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(det_cls main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(det_cls PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(det_cls PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(det_cls MMDeployStaticModules) + mmdeploy_load_dynamic(det_cls MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(det_cls PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/c/det_cls.cpp b/demo/cpp/det_cls/main.cpp similarity index 98% rename from demo/csrc/c/det_cls.cpp rename to demo/cpp/det_cls/main.cpp index 5d084dd23a..5bd77b4063 100644 --- a/demo/csrc/c/det_cls.cpp +++ b/demo/cpp/det_cls/main.cpp @@ -1,3 +1,4 @@ +// Copyright (c) OpenMMLab. All rights reserved. #include "mmdeploy/archive/json_archive.h" #include "mmdeploy/core/logger.h" diff --git a/demo/cpp/det_pose/CMakeLists.txt b/demo/cpp/det_pose/CMakeLists.txt new file mode 100644 index 0000000000..bada5b32b4 --- /dev/null +++ b/demo/cpp/det_pose/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_det_pose) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(det_pose main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(det_cls PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(det_pose PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(det_pose MMDeployStaticModules) + mmdeploy_load_dynamic(det_pose MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(det_pose PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/c/det_pose.cpp b/demo/cpp/det_pose/main.cpp similarity index 99% rename from demo/csrc/c/det_pose.cpp rename to demo/cpp/det_pose/main.cpp index a12a33ef7b..67966834b5 100644 --- a/demo/csrc/c/det_pose.cpp +++ b/demo/cpp/det_pose/main.cpp @@ -1,3 +1,4 @@ +// Copyright (c) OpenMMLab. All rights reserved. #include "mmdeploy/archive/json_archive.h" #include "mmdeploy/core/logger.h" diff --git a/demo/cpp/detector/CMakeLists.txt b/demo/cpp/detector/CMakeLists.txt new file mode 100644 index 0000000000..9f58bedaea --- /dev/null +++ b/demo/cpp/detector/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_detector) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(detector main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(detector PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(detector PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(detector MMDeployStaticModules) + mmdeploy_load_dynamic(detector MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(detector PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/cpp/detector.cxx b/demo/cpp/detector/main.cpp similarity index 53% rename from demo/csrc/cpp/detector.cxx rename to demo/cpp/detector/main.cpp index 7009d2fd21..a8fdfdd137 100644 --- a/demo/csrc/cpp/detector.cxx +++ b/demo/cpp/detector/main.cpp @@ -1,36 +1,50 @@ +// Copyright (c) OpenMMLab. All rights reserved. + #include "mmdeploy/detector.hpp" -#include -#include +#include +#include +#include +#include #include int main(int argc, char* argv[]) { - if (argc != 4) { - fprintf(stderr, "usage:\n object_detection device_name model_path image_path\n"); + if (argc < 4) { + std::cerr << "usage:" << std::endl + << " ./pose_detector device_name sdk_model_path " + "image_path [--profile]" + << std::endl; return 1; } auto device_name = argv[1]; auto model_path = argv[2]; auto image_path = argv[3]; + auto profile = argc > 4 ? std::string("--profile") == argv[argc - 1] : false; + + mmdeploy::Context context(mmdeploy::Device{device_name}); + mmdeploy::Profiler profiler("profiler.bin"); + if (profile) { + context.Add(profiler); + } + + mmdeploy::Detector detector(mmdeploy::Model(model_path), context); + cv::Mat img = cv::imread(image_path); if (!img.data) { - fprintf(stderr, "failed to load image: %s\n", image_path); + std::cerr << "failed to load image: " << image_path; return 1; } - mmdeploy::Model model(model_path); - mmdeploy::Detector detector(model, mmdeploy::Device{device_name, 0}); - auto dets = detector.Apply(img); - fprintf(stdout, "bbox_count=%d\n", (int)dets.size()); + std::cout << "bbox_count: " << (int)dets.size() << std::endl; for (int i = 0; i < dets.size(); ++i) { const auto& box = dets[i].bbox; const auto& mask = dets[i].mask; - - fprintf(stdout, "box %d, left=%.2f, top=%.2f, right=%.2f, bottom=%.2f, label=%d, score=%.4f\n", - i, box.left, box.top, box.right, box.bottom, dets[i].label_id, dets[i].score); + std::cout << "box[" << i << "]: (ltrb)[" << std::fixed << std::setprecision(2) << box.left + << box.top << box.right << box.bottom << "], label: " << dets[i].label_id + << ", score: " << dets[i].score << std::endl; // skip detections with invalid bbox size (bbox height or width < 1) if ((box.right - box.left) < 1 || (box.bottom - box.top) < 1) { @@ -44,7 +58,8 @@ int main(int argc, char* argv[]) { // generate mask overlay if model exports masks if (mask != nullptr) { - fprintf(stdout, "mask %d, height=%d, width=%d\n", i, mask->height, mask->width); + std::cout << "mask[" << i << "]: height: " << mask->height << ", width: " << mask->width + << std::endl; cv::Mat imgMask(mask->height, mask->width, CV_8UC1, &mask->data[0]); auto x0 = std::max(std::floor(box.left) - 1, 0.f); @@ -54,8 +69,7 @@ int main(int argc, char* argv[]) { // split the RGB channels, overlay mask to a specific color channel cv::Mat ch[3]; split(img, ch); - int col = 0; // int col = i % 3; - cv::bitwise_or(imgMask, ch[col](roi), ch[col](roi)); + cv::bitwise_or(imgMask, ch[0](roi), ch[0](roi)); merge(ch, 3, img); } diff --git a/demo/cpp/ocr/CMakeLists.txt b/demo/cpp/ocr/CMakeLists.txt new file mode 100644 index 0000000000..ce4155c75f --- /dev/null +++ b/demo/cpp/ocr/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_ocr) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +macro(link_mmdeploy target_name) + if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(${target_name} PRIVATE -Wl,--disable-new-dtags) + endif () + if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(${target_name} PRIVATE mmdeploy ${OpenCV_LIBS}) + else () + # Load MMDeploy modules + mmdeploy_load_static(${target_name} MMDeployStaticModules) + mmdeploy_load_dynamic(${target_name} MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(${target_name} PRIVATE MMDeployLibs ${OpenCV_LIBS}) + endif () +endmacro() + +add_executable(ocr main.cpp) +add_executable(ocr2 text_det_recog.cpp) + +link_mmdeploy(ocr) +link_mmdeploy(ocr2) diff --git a/demo/csrc/cpp/text_ocr.cxx b/demo/cpp/ocr/main.cpp similarity index 91% rename from demo/csrc/cpp/text_ocr.cxx rename to demo/cpp/ocr/main.cpp index 853d681071..0146318f49 100644 --- a/demo/csrc/cpp/text_ocr.cxx +++ b/demo/cpp/ocr/main.cpp @@ -1,6 +1,7 @@ +// Copyright (c) OpenMMLab. All rights reserved. -#include -#include +#include +#include #include #include "mmdeploy/text_detector.hpp" diff --git a/demo/csrc/cpp/text_det_recog.cxx b/demo/cpp/ocr/text_det_recog.cpp similarity index 97% rename from demo/csrc/cpp/text_det_recog.cxx rename to demo/cpp/ocr/text_det_recog.cpp index 66d25847b9..3f756d0e90 100644 --- a/demo/csrc/cpp/text_det_recog.cxx +++ b/demo/cpp/ocr/text_det_recog.cpp @@ -1,3 +1,4 @@ +// Copyright (c) OpenMMLab. All rights reserved. #include "mmdeploy/archive/json_archive.h" #include "mmdeploy/core/utils/formatter.h" diff --git a/demo/cpp/pose_detector/CMakeLists.txt b/demo/cpp/pose_detector/CMakeLists.txt new file mode 100644 index 0000000000..a18eb47f73 --- /dev/null +++ b/demo/cpp/pose_detector/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_pose_detector) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(pose_detector main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(pose_detector PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(pose_detector PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(pose_detector MMDeployStaticModules) + mmdeploy_load_dynamic(pose_detector MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(pose_detector PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/cpp/pose_detector/main.cpp b/demo/cpp/pose_detector/main.cpp new file mode 100644 index 0000000000..fdeb42dd11 --- /dev/null +++ b/demo/cpp/pose_detector/main.cpp @@ -0,0 +1,44 @@ +// Copyright (c) OpenMMLab. All rights reserved. + +#include "mmdeploy/pose_detector.hpp" + +#include +#include +#include +#include + +int main(int argc, char *argv[]) { + if (argc < 4) { + std::cerr << "usage:" << std::endl + << " ./pose_detector device_name sdk_model_path " + "image_path [--profile]" + << std::endl; + return 1; + } + auto device_name = argv[1]; + auto model_path = argv[2]; + auto image_path = argv[3]; + auto profile = argc > 4 ? std::string("--profile") == argv[argc - 1] : false; + + mmdeploy::Context context(mmdeploy::Device{device_name}); + mmdeploy::Profiler profiler("profiler.bin"); + if (profile) { + context.Add(profiler); + } + + mmdeploy::PoseDetector detector{mmdeploy::Model(model_path), context}; + + cv::Mat img = cv::imread(image_path); + if (!img.data) { + std::cerr << "failed to load image: " << image_path << std::endl; + return 1; + } + auto res = detector.Apply(img); + + for (int i = 0; i < res[0].length; i++) { + cv::circle(img, {(int)res[0].point[i].x, (int)res[0].point[i].y}, 1, {0, 255, 0}, 2); + } + cv::imwrite("output_pose.png", img); + + return 0; +} diff --git a/demo/cpp/pose_tracker/CMakeLists.txt b/demo/cpp/pose_tracker/CMakeLists.txt new file mode 100644 index 0000000000..7faaa1d793 --- /dev/null +++ b/demo/cpp/pose_tracker/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_pose_tracker) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(pose_tracker main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(pose_tracker PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(pose_tracker PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(pose_tracker MMDeployStaticModules) + mmdeploy_load_dynamic(pose_tracker MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(pose_tracker PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/cpp/pose_tracker.cpp b/demo/cpp/pose_tracker/main.cpp similarity index 99% rename from demo/csrc/cpp/pose_tracker.cpp rename to demo/cpp/pose_tracker/main.cpp index ec95afe03d..48ed19a525 100644 --- a/demo/csrc/cpp/pose_tracker.cpp +++ b/demo/cpp/pose_tracker/main.cpp @@ -1,4 +1,4 @@ - +// Copyright (c) OpenMMLab. All rights reserved. #include #include diff --git a/demo/cpp/restorer/CMakeLists.txt b/demo/cpp/restorer/CMakeLists.txt new file mode 100644 index 0000000000..d3423017ae --- /dev/null +++ b/demo/cpp/restorer/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_restorer) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(restorer main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(restorer PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(restorer PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(restorer MMDeployStaticModules) + mmdeploy_load_dynamic(restorer MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(restorer PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/cpp/restorer.cxx b/demo/cpp/restorer/main.cpp similarity index 51% rename from demo/csrc/cpp/restorer.cxx rename to demo/cpp/restorer/main.cpp index 7c3eefd82c..3730f1879a 100644 --- a/demo/csrc/cpp/restorer.cxx +++ b/demo/cpp/restorer/main.cpp @@ -2,28 +2,37 @@ #include "mmdeploy/restorer.hpp" +#include #include #include #include int main(int argc, char* argv[]) { - if (argc != 4) { - fprintf(stderr, "usage:\n image_restorer device_name model_path image_path\n"); + if (argc < 4) { + std::cerr << "usage:" << std::endl + << " ./restorer device_name sdk_model_path " + "image_path [--profile]" + << std::endl; return 1; } auto device_name = argv[1]; auto model_path = argv[2]; auto image_path = argv[3]; + auto profile = argc > 4 ? std::string("--profile") == argv[argc - 1] : false; + + mmdeploy::Context context(mmdeploy::Device{device_name}); + mmdeploy::Profiler profiler("profiler.bin"); + if (profile) { + context.Add(profiler); + } + + mmdeploy::Restorer restorer{mmdeploy::Model{model_path}, context}; + cv::Mat img = cv::imread(image_path); if (!img.data) { - fprintf(stderr, "failed to load image: %s\n", image_path); + std::cerr << "failed to load image: " << image_path << std::endl; return 1; } - - using namespace mmdeploy; - - Restorer restorer{Model{model_path}, Device{device_name}}; - auto result = restorer.Apply(img); cv::Mat sr_img(result->height, result->width, CV_8UC3, result->data); diff --git a/demo/cpp/rotated_detector/CMakeLists.txt b/demo/cpp/rotated_detector/CMakeLists.txt new file mode 100644 index 0000000000..be6fac5133 --- /dev/null +++ b/demo/cpp/rotated_detector/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_rotated_detector) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(rotated_detector main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(rotated_detector PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(rotated_detector PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(rotated_detector MMDeployStaticModules) + mmdeploy_load_dynamic(rotated_detector MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(rotated_detector PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/cpp/rotated_detector.cxx b/demo/cpp/rotated_detector/main.cpp similarity index 91% rename from demo/csrc/cpp/rotated_detector.cxx rename to demo/cpp/rotated_detector/main.cpp index d590273d32..c41e7e671e 100644 --- a/demo/csrc/cpp/rotated_detector.cxx +++ b/demo/cpp/rotated_detector/main.cpp @@ -1,3 +1,4 @@ +// Copyright (c) OpenMMLab. All rights reserved. #include "mmdeploy/rotated_detector.hpp" @@ -7,7 +8,7 @@ int main(int argc, char* argv[]) { if (argc != 4) { - fprintf(stderr, "usage:\n oriented_object_detection device_name model_path image_path\n"); + fprintf(stderr, "usage:\n rotated_detector device_name model_path image_path\n"); return 1; } auto device_name = argv[1]; diff --git a/demo/cpp/segmentor/CMakeLists.txt b/demo/cpp/segmentor/CMakeLists.txt new file mode 100644 index 0000000000..e4c29e2381 --- /dev/null +++ b/demo/cpp/segmentor/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_segmentor) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(segmentor main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(segmentor PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(segmentor PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(segmentor MMDeployStaticModules) + mmdeploy_load_dynamic(segmentor MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(segmentor PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/cpp/segmentor.cxx b/demo/cpp/segmentor/main.cpp similarity index 69% rename from demo/csrc/cpp/segmentor.cxx rename to demo/cpp/segmentor/main.cpp index 0c1dde49d6..b080b8e1d7 100644 --- a/demo/csrc/cpp/segmentor.cxx +++ b/demo/cpp/segmentor/main.cpp @@ -2,9 +2,8 @@ #include "mmdeploy/segmentor.hpp" -#include -#include -#include +#include +#include #include #include #include @@ -24,23 +23,31 @@ vector gen_palette(int num_classes) { } int main(int argc, char* argv[]) { - if (argc != 4) { - fprintf(stderr, "usage:\n image_segmentation device_name model_path image_path\n"); + if (argc < 4) { + std::cerr << "usage:" << std::endl + << " ./segmentor device_name sdk_model_path " + "image_path [--profile]" + << std::endl; return 1; } auto device_name = argv[1]; auto model_path = argv[2]; auto image_path = argv[3]; + auto profile = argc > 4 ? std::string("--profile") == argv[argc - 1] : false; + + mmdeploy::Context context(mmdeploy::Device{device_name}); + mmdeploy::Profiler profiler("profiler.bin"); + if (profile) { + context.Add(profiler); + } + + mmdeploy::Segmentor segmentor{mmdeploy::Model{model_path}, context}; + cv::Mat img = cv::imread(image_path); if (!img.data) { fprintf(stderr, "failed to load image: %s\n", image_path); return 1; } - - using namespace mmdeploy; - - Segmentor segmentor{Model{model_path}, Device{device_name}}; - auto result = segmentor.Apply(img); auto palette = gen_palette(result->classes + 1); diff --git a/demo/cpp/video_recognizer/CMakeLists.txt b/demo/cpp/video_recognizer/CMakeLists.txt new file mode 100644 index 0000000000..80099345fe --- /dev/null +++ b/demo/cpp/video_recognizer/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +cmake_minimum_required(VERSION 3.14) +project(mmdeploy_cxxapi_video_recognizer) + +if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) + find_package(MMDeploy REQUIRED) +endif () + +find_package(OpenCV REQUIRED) + +add_executable(video_recognizer main.cpp) + +if (NOT (MSVC OR APPLE)) + # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set + target_link_libraries(video_recognizer PRIVATE -Wl,--disable-new-dtags) +endif () +if (MMDEPLOY_BUILD_SDK_MONOLITHIC) + target_link_libraries(video_recognizer PRIVATE mmdeploy ${OpenCV_LIBS}) +else () + # Load MMDeploy modules + mmdeploy_load_static(video_recognizer MMDeployStaticModules) + mmdeploy_load_dynamic(video_recognizer MMDeployDynamicModules) + # Link to MMDeploy libraries + target_link_libraries(video_recognizer PRIVATE MMDeployLibs ${OpenCV_LIBS}) +endif () diff --git a/demo/csrc/cpp/video_cls.cxx b/demo/cpp/video_recognizer/main.cpp similarity index 68% rename from demo/csrc/cpp/video_cls.cxx rename to demo/cpp/video_recognizer/main.cpp index 95c9ef239e..f3221e73d9 100644 --- a/demo/csrc/cpp/video_cls.cxx +++ b/demo/cpp/video_recognizer/main.cpp @@ -1,22 +1,24 @@ +// Copyright (c) OpenMMLab. All rights reserved. +#include +#include #include +#include #include #include "mmdeploy/video_recognizer.hpp" -#include "opencv2/imgcodecs/imgcodecs.hpp" -#include "opencv2/videoio.hpp" void SampleFrames(const char* video_path, std::map& buffer, std::vector& clips, int clip_len, int frame_interval = 1, int num_clips = 1) { cv::VideoCapture cap = cv::VideoCapture(video_path); if (!cap.isOpened()) { - fprintf(stderr, "failed to load video: %s\n", video_path); + std::cerr << "failed to load video: " << video_path << std::endl; exit(1); } int num_frames = cap.get(cv::CAP_PROP_FRAME_COUNT); - printf("num_frames %d\n", num_frames); + std::cout << "num_frames: " << num_frames << std::endl; int ori_clip_len = clip_len * frame_interval; float avg_interval = (num_frames - ori_clip_len + 1.f) / num_clips; @@ -38,8 +40,7 @@ void SampleFrames(const char* video_path, std::map& buffer, unique_inds.erase(last, unique_inds.end()); int ind = 0; - for (int i = 0; i < unique_inds.size(); i++) { - int tid = unique_inds[i]; + for (int tid : unique_inds) { cv::Mat frame; while (ind < tid) { cap.read(frame); @@ -58,13 +59,26 @@ void SampleFrames(const char* video_path, std::map& buffer, } int main(int argc, char* argv[]) { - if (argc != 4) { - fprintf(stderr, "usage:\n video_cls device_name model_path video_path\n"); + if (argc < 4) { + std::cerr << "usage:" << std::endl + << " ./video_cls device_name sdk_model_path " + "video_path [--profile]" + << std::endl; return 1; } + auto device_name = argv[1]; auto model_path = argv[2]; auto video_path = argv[3]; + auto profile = argc > 4 ? std::string("--profile") == argv[argc - 1] : false; + + mmdeploy::Context context(mmdeploy::Device{device_name, 0}); + mmdeploy::Profiler profiler("profiler.bin"); + if (profile) { + context.Add(profiler); + } + + mmdeploy::VideoRecognizer recognizer( mmdeploy::Model{model_path}, context); int clip_len = 1; int frame_interval = 1; @@ -75,13 +89,11 @@ int main(int argc, char* argv[]) { mmdeploy::VideoSampleInfo clip_info = {clip_len, num_clips}; SampleFrames(video_path, buffer, clips, clip_len, frame_interval, num_clips); - mmdeploy::Model model(model_path); - mmdeploy::VideoRecognizer recognizer(model, mmdeploy::Device{device_name, 0}); - auto res = recognizer.Apply(clips, clip_info); for (const auto& cls : res) { - fprintf(stderr, "label: %d, score: %.4f\n", cls.label_id, cls.score); + std::cout << "label: " << cls.label_id << ", score: " << std::fixed << std::setprecision(2) + << cls.score << std::endl; } return 0; diff --git a/demo/csrc/CMakeLists.txt b/demo/csrc/CMakeLists.txt deleted file mode 100644 index 85ffc6f32c..0000000000 --- a/demo/csrc/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -cmake_minimum_required(VERSION 3.14) -project(mmdeploy-example) - -if (NOT (${CMAKE_PROJECT_NAME} STREQUAL "MMDeploy")) - find_package(MMDeploy REQUIRED) -endif () - - -function(add_example dep folder name) - if (NOT dep OR TARGET mmdeploy_${dep}) - # Search for c/cpp sources - file(GLOB _SRCS ${folder}/${name}.c*) - add_executable(${name} ${_SRCS}) - if (NOT (MSVC OR APPLE)) - # Disable new dtags so that executables can run even without LD_LIBRARY_PATH set - target_link_libraries(${name} PRIVATE -Wl,--disable-new-dtags) - endif () - if (MMDEPLOY_BUILD_SDK_MONOLITHIC) - target_link_libraries(${name} PRIVATE mmdeploy ${OpenCV_LIBS}) - else () - # Load MMDeploy modules - mmdeploy_load_static(${name} MMDeployStaticModules) - mmdeploy_load_dynamic(${name} MMDeployDynamicModules) - # Link to MMDeploy libraries - target_link_libraries(${name} PRIVATE MMDeployLibs ${OpenCV_LIBS}) - endif () - install(TARGETS ${name} RUNTIME DESTINATION bin) - endif () -endfunction() - -add_example(classifier c image_classification) -add_example(classifier c batch_image_classification) -add_example(detector c object_detection) -add_example(detector c batch_object_detection) -add_example(segmentor c image_segmentation) -add_example(restorer c image_restorer) -add_example(text_detector c ocr) -add_example(pose_detector c pose_detection) -add_example(rotated_detector c rotated_object_detection) -add_example(video_recognizer c video_recognition) -# TODO: figure out a better way -# add_example("" c det_cls) -# add_example("" c det_pose) - -if (MMDEPLOY_BUILD_SDK_CXX_API) - add_example(classifier cpp classifier) - add_example(detector cpp detector) - add_example(segmentor cpp segmentor) - add_example(restorer cpp restorer) - add_example(text_detector cpp text_ocr) - add_example(text_detector cpp text_det_recog) - add_example(pose_detector cpp pose_detector) - add_example(rotated_detector cpp rotated_detector) - add_example(pose_detector cpp pose_tracker) - add_example(video_recognizer cpp video_cls) -endif () diff --git a/demo/csrc/cpp/classifier.cxx b/demo/csrc/cpp/classifier.cxx deleted file mode 100644 index 2d8b2d1e25..0000000000 --- a/demo/csrc/cpp/classifier.cxx +++ /dev/null @@ -1,32 +0,0 @@ - -#include "mmdeploy/classifier.hpp" - -#include - -#include "opencv2/imgcodecs/imgcodecs.hpp" - -int main(int argc, char* argv[]) { - if (argc != 4) { - fprintf(stderr, "usage:\n image_classification device_name model_path image_path\n"); - return 1; - } - auto device_name = argv[1]; - auto model_path = argv[2]; - auto image_path = argv[3]; - cv::Mat img = cv::imread(image_path); - if (!img.data) { - fprintf(stderr, "failed to load image: %s\n", image_path); - return 1; - } - - mmdeploy::Model model(model_path); - mmdeploy::Classifier classifier(model, mmdeploy::Device{device_name, 0}); - - auto res = classifier.Apply(img); - - for (const auto& cls : res) { - fprintf(stderr, "label: %d, score: %.4f\n", cls.label_id, cls.score); - } - - return 0; -} diff --git a/demo/csrc/cpp/pose_detector.cxx b/demo/csrc/cpp/pose_detector.cxx deleted file mode 100644 index 6b0803d1b9..0000000000 --- a/demo/csrc/cpp/pose_detector.cxx +++ /dev/null @@ -1,33 +0,0 @@ - -#include "mmdeploy/pose_detector.hpp" - -#include -#include -#include - -int main(int argc, char *argv[]) { - if (argc != 4) { - fprintf(stderr, "usage:\n pose_detection device_name model_path image_path\n"); - return 1; - } - auto device_name = argv[1]; - auto model_path = argv[2]; - auto image_path = argv[3]; - cv::Mat img = cv::imread(image_path); - if (!img.data) { - fprintf(stderr, "failed to load image: %s\n", image_path); - return 1; - } - - using namespace mmdeploy; - - PoseDetector detector{Model(model_path), Device(device_name)}; - auto res = detector.Apply(img); - - for (int i = 0; i < res[0].length; i++) { - cv::circle(img, {(int)res[0].point[i].x, (int)res[0].point[i].y}, 1, {0, 255, 0}, 2); - } - cv::imwrite("output_pose.png", img); - - return 0; -} diff --git a/docs/en/01-how-to-build/cmake_option.md b/docs/en/01-how-to-build/cmake_option.md index 7e036aea54..c0ca421c1a 100644 --- a/docs/en/01-how-to-build/cmake_option.md +++ b/docs/en/01-how-to-build/cmake_option.md @@ -43,12 +43,6 @@ OFF Switch to build MMDeploy SDK python package - - MMDEPLOY_BUILD_SDK_CXX_API - {ON, OFF} - OFF - Build C++ SDK API - MMDEPLOY_BUILD_SDK_CSHARP_API @@ -109,20 +103,20 @@ -DTENSORRT_DIR=${TENSORRT_DIR} -DCUDNN_DIR=${CUDNN_DIR} - 2. ort: ONNXRuntime. ONNXRUNTIME_DIR is needed. + 1. ort: ONNXRuntime. ONNXRUNTIME_DIR is needed.
-DONNXRUNTIME_DIR=${ONNXRUNTIME_DIR}
- 3. pplnn: PPL.NN. pplnn_DIR is needed. + 2. pplnn: PPL.NN. pplnn_DIR is needed.
-Dpplnn_DIR=${PPLNN_DIR}
- 4. ncnn: ncnn. ncnn_DIR is needed. + 3. ncnn: ncnn. ncnn_DIR is needed.
-Dncnn_DIR=${NCNN_DIR}/build/install/lib/cmake/ncnn
- 5. openvino: OpenVINO. InferenceEngine_DIR is needed. + 4. openvino: OpenVINO. InferenceEngine_DIR is needed.
-DInferenceEngine_DIR=${INTEL_OPENVINO_DIR}/deployment_tools/inference_engine/share
- 6. torchscript: TorchScript. Torch_DIR is needed. + 5. torchscript: TorchScript. Torch_DIR is needed.
-DTorch_DIR=${Torch_DIR}
Currently, The Model Converter supports torchscript, but SDK doesn't.
- 7. snpe: qcom snpe. SNPE_ROOT must existed in the environment variable because of C/S mode.
- 8. coreml: CoreML. Torch_DIR is required. Torch_DIR
- 9. TVM: TVM. TVM_DIR is required.
-DTVM_DIR=${TVM_DIR}
+ 6. snpe: qcom snpe. SNPE_ROOT must existed in the environment variable because of C/S mode.
+ 7. coreml: CoreML. Torch_DIR is required. Torch_DIR
+ 8. TVM: TVM. TVM_DIR is required.
-DTVM_DIR=${TVM_DIR}
diff --git a/docs/zh_cn/01-how-to-build/cmake_option.md b/docs/zh_cn/01-how-to-build/cmake_option.md index eae4d8926b..81d600e32d 100644 --- a/docs/zh_cn/01-how-to-build/cmake_option.md +++ b/docs/zh_cn/01-how-to-build/cmake_option.md @@ -46,13 +46,6 @@ SDK python package的编译开关 - - MMDEPLOY_BUILD_SDK_CXX_API - {ON, OFF} - OFF - SDK C++ package的编译开关 - - MMDEPLOY_BUILD_SDK_CSHARP_API {ON, OFF} @@ -113,15 +106,15 @@ -DTENSORRT_DIR=$env:TENSORRT_DIR -DCUDNN_DIR=$env:CUDNN_DIR - 2. ort: 表示 ONNXRuntime。需要设置 ONNXRUNTIME_DIR。 + 1. ort: 表示 ONNXRuntime。需要设置 ONNXRUNTIME_DIR
-DONNXRUNTIME_DIR=$env:ONNXRUNTIME_DIR
- 3. pplnn: 表示 PPL.NN。需要设置 pplnn_DIR
- 4. ncnn:表示 ncnn。需要设置 ncnn_DIR
- 5. openvino: 表示 OpenVINO。需要设置 InferenceEngine_DIR
- 6. torchscript: 表示 TorchScript。目前仅模型转换支持 torchscript 格式,SDK 尚未支持。
- 7. snpe: 表示 qcom snpe。需要环境变量设置 SNPE_ROOT。
- 8. coreml: 表示 Core ML。目前在进行模型转换时需要设置 Torch_DIR
- 9. tvm: 表示 TVM。需要设置 TVM_DIR
+ 1. pplnn: 表示 PPL.NN。需要设置 pplnn_DIR
+ 2. ncnn:表示 ncnn。需要设置 ncnn_DIR
+ 3. openvino: 表示 OpenVINO。需要设置 InferenceEngine_DIR
+ 4. torchscript: 表示 TorchScript。目前仅模型转换支持 torchscript 格式,SDK 尚未支持。
+ 5. snpe: 表示 qcom snpe。需要环境变量设置 SNPE_ROOT。
+ 6. coreml: 表示 Core ML。目前在进行模型转换时需要设置 Torch_DIR
+ 7. tvm: 表示 TVM。需要设置 TVM_DIR
diff --git a/docs/zh_cn/01-how-to-build/rockchip.md b/docs/zh_cn/01-how-to-build/rockchip.md index 2b7722c504..1a645308b8 100644 --- a/docs/zh_cn/01-how-to-build/rockchip.md +++ b/docs/zh_cn/01-how-to-build/rockchip.md @@ -1,12 +1,15 @@ # 瑞芯微 NPU 部署 -- [模型转换](#模型转换) - - [安装环境](#安装环境) - - [分裂模型转换](#分类模型转换) - - [检测模型转换](#检测模型转换) -- [模型推理](#模型推理) - - [Host 交叉编译](#Host-交叉编译) - - [Device 执行推理](#Device-执行推理) +- [瑞芯微 NPU 部署](#瑞芯微-npu-部署) + - [模型转换](#模型转换) + - [安装环境](#安装环境) + - [分类模型转换](#分类模型转换) + - [检测模型转换](#检测模型转换) + - [部署 config 说明](#部署-config-说明) + - [问题说明](#问题说明) + - [模型推理](#模型推理) + - [Host 交叉编译](#host-交叉编译) + - [Device 执行推理](#device-执行推理) ______________________________________________________________________ @@ -234,7 +237,6 @@ mkdir -p build && cd build cmake .. \ -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/arm-linux-gnueabihf.cmake \ -DMMDEPLOY_BUILD_SDK=ON \ --DMMDEPLOY_BUILD_SDK_CXX_API=ON \ -DMMDEPLOY_BUILD_EXAMPLES=ON \ -DMMDEPLOY_TARGET_BACKENDS="rknn" \ -DRKNPU_DEVICE_DIR=${RKNPU_DIR}/rknn/rknn_api/librknn_api \ @@ -281,7 +283,6 @@ export LD_LIBRARY_PATH=$RKNN_TOOL_CHAIN/lib64:$LD_LIBRARY_PATH cmake \ -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/rknpu2-linux-gnu.cmake \ -DMMDEPLOY_BUILD_SDK=ON \ - -DMMDEPLOY_BUILD_SDK_CXX_API=ON \ -DMMDEPLOY_TARGET_BACKENDS="rknn" \ -DMMDEPLOY_BUILD_EXAMPLES=ON \ -DOpenCV_DIR=${OpenCV_AARCH64_INSTALL_DIR}/lib/cmake/opencv4 diff --git a/tools/package_tools/configs/linux_x64.yaml b/tools/package_tools/configs/linux_x64.yaml index f0e3b07310..f16ec644bb 100644 --- a/tools/package_tools/configs/linux_x64.yaml +++ b/tools/package_tools/configs/linux_x64.yaml @@ -3,7 +3,6 @@ global_config: CMAKE_CXX_COMPILER: "g++-7" MMDEPLOY_BUILD_SDK: "ON" MMDEPLOY_BUILD_SDK_MONOLITHIC: "ON" - MMDEPLOY_BUILD_SDK_CXX_API: "ON" MMDEPLOY_BUILD_EXAMPLES: "ON" MMDEPLOY_SHARED_LIBS: "OFF" OpenCV_DIR: "${OpenCV_DIR}" diff --git a/tools/package_tools/configs/windows_x64.yaml b/tools/package_tools/configs/windows_x64.yaml index c104a8c788..3950f18447 100644 --- a/tools/package_tools/configs/windows_x64.yaml +++ b/tools/package_tools/configs/windows_x64.yaml @@ -3,7 +3,6 @@ global_config: cmake_envs: MMDEPLOY_BUILD_SDK: "ON" MMDEPLOY_BUILD_SDK_MONOLITHIC: "ON" - MMDEPLOY_BUILD_SDK_CXX_API: "ON" MMDEPLOY_BUILD_EXAMPLES: "ON" MMDEPLOY_SHARED_LIBS: "OFF" MMDEPLOY_CODEBASES: "all" diff --git a/tools/scripts/ubuntu_cross_build_rknn.sh b/tools/scripts/ubuntu_cross_build_rknn.sh index f3f3f5501f..b9db841776 100644 --- a/tools/scripts/ubuntu_cross_build_rknn.sh +++ b/tools/scripts/ubuntu_cross_build_rknn.sh @@ -99,7 +99,6 @@ build_mmdeploy_with_rknpu() { cmake .. \ -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/arm-linux-gnueabihf.cmake \ -DMMDEPLOY_BUILD_SDK=ON \ - -DMMDEPLOY_BUILD_SDK_CXX_API=ON \ -DMMDEPLOY_BUILD_EXAMPLES=ON \ -DMMDEPLOY_TARGET_BACKENDS="rknn" \ -DRKNPU_DEVICE_DIR="${RKNPU_DIR}"/rknn/rknn_api/librknn_api \ @@ -125,7 +124,6 @@ build_mmdeploy_with_rknpu2() { cmake .. \ -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/rknpu2-linux-gnu.cmake \ -DMMDEPLOY_BUILD_SDK=ON \ - -DMMDEPLOY_BUILD_SDK_CXX_API=ON \ -DMMDEPLOY_BUILD_EXAMPLES=ON \ -DMMDEPLOY_TARGET_BACKENDS="rknn" \ -DRKNPU2_DEVICE_DIR="${RKNPU2_DIR}/runtime/${device_model}" \