add MMDEPLOY_TASKS & simplify demo cmake (#606)

* add `MMDEPLOY_TASKS` & simply cmake

* remove debug log
This commit is contained in:
Li Zhang 2022-06-17 13:56:45 +08:00 committed by GitHub
parent 296412fd08
commit a822ba7330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 42 additions and 90 deletions

View File

@ -41,6 +41,8 @@ else ()
set(MMDEPLOY_LIB_TYPE STATIC)
endif ()
set(MMDEPLOY_TASKS "" CACHE INTERNAL "")
# when CUDA devices are enabled, the environment variable ASAN_OPTIONS=protect_shadow_gap=0
# must be set at runtime
if (MMDEPLOY_ASAN_ENABLE)

View File

@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.14)
include("${CMAKE_CURRENT_LIST_DIR}/MMDeployTargets.cmake")
set(MMDEPLOY_CODEBASES @MMDEPLOY_CODEBASES@)
set(MMDEPLOY_TASKS @MMDEPLOY_TASKS@)
set(MMDEPLOY_TARGET_DEVICES @MMDEPLOY_TARGET_DEVICES@)
set(MMDEPLOY_TARGET_BACKENDS @MMDEPLOY_TARGET_BACKENDS@)
set(MMDEPLOY_BUILD_TYPE @CMAKE_BUILD_TYPE@)

View File

@ -8,42 +8,7 @@ set(COMMON_LIST
executor
pipeline)
set(TASK_LIST)
if ("all" IN_LIST MMDEPLOY_CODEBASES)
list(APPEND TASK_LIST
classifier
detector
segmentor
text_detector
text_recognizer
pose_detector
restorer
rotated_detector)
else ()
if ("mmcls" IN_LIST MMDEPLOY_CODEBASES)
list(APPEND TASK_LIST classifier)
endif ()
if ("mmdet" IN_LIST MMDEPLOY_CODEBASES)
list(APPEND TASK_LIST detector)
endif ()
if ("mmseg" IN_LIST MMDEPLOY_CODEBASES)
list(APPEND TASK_LIST segmentor)
endif ()
if ("mmedit" IN_LIST MMDEPLOY_CODEBASES)
list(APPEND TASK_LIST restorer)
endif ()
if ("mmocr" IN_LIST MMDEPLOY_CODEBASES)
list(APPEND TASK_LIST text_detector)
list(APPEND TASK_LIST text_recognizer)
endif ()
if ("mmpose" IN_LIST MMDEPLOY_CODEBASES)
list(APPEND TASK_LIST pose_detector)
endif ()
if ("mmrotate" IN_LIST MMDEPLOY_CODEBASES)
list(APPEND TASK_LIST "rotated_detector")
endif ()
endif ()
set(TASK_LIST ${MMDEPLOY_TASKS})
foreach (TASK ${COMMON_LIST})
set(TARGET_NAME mmdeploy_${TASK})

View File

@ -15,20 +15,9 @@ elseif (NOT TARGET pybind11)
add_subdirectory(${CMAKE_SOURCE_DIR}/third_party/pybind11 pybind11)
endif ()
macro(mmdeploy_python_add_module name)
if (TARGET mmdeploy_${name})
list(APPEND MMDEPLOY_PYTHON_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.cpp)
endif ()
endmacro()
mmdeploy_python_add_module(classifier)
mmdeploy_python_add_module(detector)
mmdeploy_python_add_module(segmentor)
mmdeploy_python_add_module(text_detector)
mmdeploy_python_add_module(text_recognizer)
mmdeploy_python_add_module(restorer)
mmdeploy_python_add_module(pose_detector)
mmdeploy_python_add_module(rotated_detector)
foreach (task_name ${MMDEPLOY_TASKS})
list(APPEND MMDEPLOY_PYTHON_SRCS ${task_name}.cpp)
endforeach ()
pybind11_add_module(${PROJECT_NAME} ${MMDEPLOY_PYTHON_SRCS})

View File

@ -5,3 +5,5 @@ project(mmdeploy_mmcls)
file(GLOB_RECURSE SRCS ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
mmdeploy_add_module(${PROJECT_NAME} "${SRCS}")
add_library(mmdeploy::mmcls ALIAS ${PROJECT_NAME})
set(MMDEPLOY_TASKS ${MMDEPLOY_TASKS} classifier CACHE INTERNAL "")

View File

@ -8,3 +8,5 @@ target_link_libraries(${PROJECT_NAME}
PRIVATE mmdeploy_opencv_utils)
add_library(mmdeploy::mmdet ALIAS ${PROJECT_NAME})
set(MMDEPLOY_TASKS ${MMDEPLOY_TASKS} detector CACHE INTERNAL "")

View File

@ -6,3 +6,5 @@ file(GLOB_RECURSE SRCS ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
mmdeploy_add_module(${PROJECT_NAME} "${SRCS}")
target_link_libraries(${PROJECT_NAME} PRIVATE opencv_core)
add_library(mmdeploy::mmedit ALIAS ${PROJECT_NAME})
set(MMDEPLOY_TASKS ${MMDEPLOY_TASKS} restorer CACHE INTERNAL "")

View File

@ -18,3 +18,5 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
mmdeploy::transform
mmdeploy::core)
add_library(mmdeploy::mmocr ALIAS ${PROJECT_NAME})
set(MMDEPLOY_TASKS ${MMDEPLOY_TASKS} text_detector text_recognizer CACHE INTERNAL "")

View File

@ -8,3 +8,5 @@ mmdeploy_add_module(${PROJECT_NAME} "${SRCS}")
target_link_libraries(${PROJECT_NAME} PRIVATE
mmdeploy::transform mmdeploy_opencv_utils)
add_library(mmdeploy::mmpose ALIAS ${PROJECT_NAME})
set(MMDEPLOY_TASKS ${MMDEPLOY_TASKS} pose_detector CACHE INTERNAL "")

View File

@ -6,3 +6,5 @@ file(GLOB_RECURSE SRCS ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
mmdeploy_add_module(${PROJECT_NAME} "${SRCS}")
target_link_libraries(${PROJECT_NAME} PRIVATE mmdeploy_opencv_utils)
add_library(mmdeploy::mmrotate ALIAS ${PROJECT_NAME})
set(MMDEPLOY_TASKS ${MMDEPLOY_TASKS} rotated_detector CACHE INTERNAL "")

View File

@ -6,3 +6,5 @@ file(GLOB_RECURSE SRCS ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
mmdeploy_add_module(${PROJECT_NAME} "${SRCS}")
target_link_libraries(${PROJECT_NAME} PRIVATE mmdeploy_opencv_utils)
add_library(mmdeploy::mmseg ALIAS ${PROJECT_NAME})
set(MMDEPLOY_TASKS ${MMDEPLOY_TASKS} segmentor CACHE INTERNAL "")

View File

@ -4,46 +4,27 @@ project(mmdeploy-example)
find_package(MMDeploy REQUIRED)
function(add_example name)
function(add_example task name)
if (TARGET mmdeploy_${task})
# Search for c/cpp sources
file(GLOB _SRCS ${name}.c*)
add_executable(${name} ${_SRCS})
if (NOT MSVC)
# disable new dtags so that executables can run even without LD_LIBRARY_PATH set
# Disable new dtags so that executables can run even without LD_LIBRARY_PATH set
target_link_libraries(${name} PRIVATE -Wl,--disable-new-dtags)
endif ()
# 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 ()
endfunction()
if ("all" IN_LIST MMDEPLOY_CODEBASES)
add_example(image_classification)
add_example(object_detection)
add_example(image_restorer)
add_example(image_segmentation)
add_example(pose_detection)
add_example(rotated_object_detection)
add_example(ocr)
else ()
if ("mmcls" IN_LIST MMDEPLOY_CODEBASES)
add_example(image_classification)
endif ()
if ("mmdet" IN_LIST MMDEPLOY_CODEBASES)
add_example(object_detection)
endif ()
if ("mmseg" IN_LIST MMDEPLOY_CODEBASES)
add_example(image_segmentation)
endif ()
if ("mmedit" IN_LIST MMDEPLOY_CODEBASES)
add_example(image_restorer)
endif ()
if ("mmocr" IN_LIST MMDEPLOY_CODEBASES)
add_example(ocr)
endif ()
if ("mmpose" IN_LIST MMDEPLOY_CODEBASES)
add_example(pose_detection)
endif ()
if ("mmrotate" IN_LIST MMDEPLOY_CODEBASES)
add_example(rotated_object_detection)
endif ()
endif ()
add_example(classifier image_classification)
add_example(detector object_detection)
add_example(segmentor image_segmentation)
add_example(restorer image_restorer)
add_example(text_detector ocr)
add_example(pose_detector pose_detection)
add_example(rotated_detector rotated_object_detection)