diff --git a/build/lite.ai.toolkit/lib/liblite.ai.toolkit.0.1.0.dylib b/build/lite.ai.toolkit/lib/liblite.ai.toolkit.0.1.0.dylib deleted file mode 100755 index 0ed100d6..00000000 Binary files a/build/lite.ai.toolkit/lib/liblite.ai.toolkit.0.1.0.dylib and /dev/null differ diff --git a/build/lite.ai.toolkit/lib/liblite.ai.toolkit.dylib b/build/lite.ai.toolkit/lib/liblite.ai.toolkit.dylib deleted file mode 120000 index 71f121a5..00000000 --- a/build/lite.ai.toolkit/lib/liblite.ai.toolkit.dylib +++ /dev/null @@ -1 +0,0 @@ -liblite.ai.toolkit.0.1.0.dylib \ No newline at end of file diff --git a/cmake/lite.ai.toolkit-cmd.cmake b/cmake/lite.ai.toolkit-cmd.cmake index a9be4db4..5c845ee8 100644 --- a/cmake/lite.ai.toolkit-cmd.cmake +++ b/cmake/lite.ai.toolkit-cmd.cmake @@ -21,7 +21,7 @@ function(add_lite_ai_toolkit_shared_library version soversion) if (ENABLE_MNN) include(cmake/lite.ai.toolkit-mnn.cmake) set(LITE_SRCS ${LITE_SRCS} ${MNN_SRCS}) - set(LITE_DEPENDENCIES ${LITE_DEPENDENCIES} mnn) + set(LITE_DEPENDENCIES ${LITE_DEPENDENCIES} MNN) endif() if (ENABLE_NCNN) @@ -33,7 +33,7 @@ function(add_lite_ai_toolkit_shared_library version soversion) if (ENABLE_TNN) include(cmake/lite.ai.toolkit-tnn.cmake) set(LITE_SRCS ${LITE_SRCS} ${TNN_SRCS}) - set(LITE_DEPENDENCIES ${LITE_DEPENDENCIES} tnn) + set(LITE_DEPENDENCIES ${LITE_DEPENDENCIES} TNN) endif() # 4. shared library @@ -51,7 +51,7 @@ function(add_lite_ai_toolkit_shared_library version soversion) endfunction() # add custom command for lite.ai shared lib. -function(add_lite_ai_toolkit_custom_command) +function(add_lite_ai_toolkit_pre_custom_command) if (LITE_AI_BUILD_TEST) add_custom_command(TARGET lite.ai.toolkit PRE_BUILD @@ -60,6 +60,11 @@ function(add_lite_ai_toolkit_custom_command) COMMAND ${CMAKE_COMMAND} -E echo "create ${LIBRARY_OUTPUT_PATH} done!" COMMAND ${CMAKE_COMMAND} -E echo "create ${EXECUTABLE_OUTPUT_PATH} done!" ) + endif() +endfunction() + +function(add_lite_ai_toolkit_post_custom_command) + if (LITE_AI_BUILD_TEST) # copy opencv & lite.ai libs. add_custom_command(TARGET lite.ai.toolkit POST_BUILD @@ -111,39 +116,3 @@ function(add_lite_executable executable_name field) target_link_libraries(${executable_name} lite.ai.toolkit) # link lite.ai.toolkit message(">>>> Added Lite Executable: ${executable_name} !") endfunction () - -function(add_ort_executable executable_name field) - if (NOT ${THIRDPARTY_SET_STATE}) - include(${CMAKE_SOURCE_DIR}/cmake/setup_3rdparty.cmake) - endif() - add_executable(${executable_name} ${field}/test_${executable_name}.cpp) - target_link_libraries(${executable_name} lite.ai.toolkit) # link lite.ai.toolkit - message(">>>> Added Ort Executable: ${executable_name} !") -endfunction () - -function(add_mnn_executable executable_name field) - if (NOT ${THIRDPARTY_SET_STATE}) - include(${CMAKE_SOURCE_DIR}/cmake/setup_3rdparty.cmake) - endif() - add_executable(${executable_name} ${field}/test_${executable_name}.cpp) - target_link_libraries(${executable_name} lite.ai.toolkit) # link lite.ai.toolkit - message(">>>> Added MNN Executable: ${executable_name} !") -endfunction () - -function(add_ncnn_executable executable_name field) - if (NOT ${THIRDPARTY_SET_STATE}) - include(${CMAKE_SOURCE_DIR}/cmake/setup_3rdparty.cmake) - endif() - add_executable(${executable_name} ${field}/test_${executable_name}.cpp) - target_link_libraries(${executable_name} lite.ai.toolkit) # link lite.ai.toolkit - message(">>>> Added NCNN Executable: ${executable_name} !") -endfunction () - -function(add_tnn_executable executable_name field) - if (NOT ${THIRDPARTY_SET_STATE}) - include(${CMAKE_SOURCE_DIR}/cmake/setup_3rdparty.cmake) - endif() - add_executable(${executable_name} ${field}/test_${executable_name}.cpp) - target_link_libraries(${executable_name} lite.ai.toolkit) # link lite.ai.toolkit - message(">>>> Added TNN Executable: ${executable_name} !") -endfunction () \ No newline at end of file diff --git a/cmake/lite.ai.toolkit.cmake b/cmake/lite.ai.toolkit.cmake index ad02d72e..1a134b95 100644 --- a/cmake/lite.ai.toolkit.cmake +++ b/cmake/lite.ai.toolkit.cmake @@ -1,5 +1,8 @@ add_lite_ai_toolkit_shared_library(${VERSION_STRING} ${SOVERSION_STRING}) -add_lite_ai_toolkit_custom_command() +add_lite_ai_toolkit_pre_custom_command() +if(${PLATFORM_NAME} MATCHES macos OR ${PLATFORM_NAME} MATCHES linux) + add_lite_ai_toolkit_post_custom_command() +endif() diff --git a/mnn/core/mnn_utils.h b/mnn/core/mnn_utils.h index faf67e0e..ada5f49b 100644 --- a/mnn/core/mnn_utils.h +++ b/mnn/core/mnn_utils.h @@ -102,7 +102,7 @@ template std::vector mnncv::utils::math::softmax(const T *logits, unsigned int _size, unsigned int &max_id) { types::__assert_type(); - if (_size == 0 or logits == nullptr) return {}; + if (_size == 0 || logits == nullptr) return {}; T max_prob = static_cast(0), total_exp = static_cast(0); std::vector softmax_probs(_size); for (unsigned int i = 0; i < _size; ++i) diff --git a/mnn/cv/mnn_nanodet.cpp b/mnn/cv/mnn_nanodet.cpp index d36e6828..60742001 100644 --- a/mnn/cv/mnn_nanodet.cpp +++ b/mnn/cv/mnn_nanodet.cpp @@ -13,7 +13,7 @@ MNNNanoDet::MNNNanoDet(const std::string _mnn_path, unsigned int _num_threads) : initialize_pretreat(); } -void MNNNanoDet::initialize_pretreat() +inline void MNNNanoDet::initialize_pretreat() { pretreat = std::shared_ptr( MNN::CV::ImageProcess::create( @@ -25,7 +25,7 @@ void MNNNanoDet::initialize_pretreat() ); } -void MNNNanoDet::transform(const cv::Mat &mat_rs) +inline void MNNNanoDet::transform(const cv::Mat &mat_rs) { pretreat->convert(mat_rs.data, input_width, input_height, mat_rs.step[0], input_tensor); } @@ -109,7 +109,15 @@ void MNNNanoDet::generate_points(unsigned int target_height, unsigned int target { float grid0 = (float) g0 + 0.5f; float grid1 = (float) g1 + 0.5f; +#ifdef LITE_WIN32 + NanoCenterPoint point; + point.grid0 = grid0; + point.grid1 = grid1; + point.stride = (float) stride; + points.push_back(point); +#else points.push_back((NanoCenterPoint) {grid0, grid1, (float) stride}); +#endif } } center_points[stride] = points; diff --git a/mnn/cv/mnn_nanodet_efficientnet_lite.cpp b/mnn/cv/mnn_nanodet_efficientnet_lite.cpp index ecc775a5..c27e15c0 100644 --- a/mnn/cv/mnn_nanodet_efficientnet_lite.cpp +++ b/mnn/cv/mnn_nanodet_efficientnet_lite.cpp @@ -109,7 +109,15 @@ void MNNNanoDetEfficientNetLite::generate_points(unsigned int target_height, uns { float grid0 = (float) g0 + 0.5f; float grid1 = (float) g1 + 0.5f; +#ifdef LITE_WIN32 + NanoLiteCenterPoint point; + point.grid0 = grid0; + point.grid1 = grid1; + point.stride = (float) stride; + points.push_back(point); +#else points.push_back((NanoLiteCenterPoint) {grid0, grid1, (float) stride}); +#endif } } center_points[stride] = points; diff --git a/ort/core/ort_utils.h b/ort/core/ort_utils.h index caf4eeb3..6ec799b8 100644 --- a/ort/core/ort_utils.h +++ b/ort/core/ort_utils.h @@ -134,7 +134,7 @@ template std::vector ortcv::utils::math::softmax(const T *logits, unsigned int _size, unsigned int &max_id) { types::__assert_type(); - if (_size == 0 or logits == nullptr) return {}; + if (_size == 0 || logits == nullptr) return {}; T max_prob = static_cast(0), total_exp = static_cast(0); std::vector softmax_probs(_size); for (unsigned int i = 0; i < _size; ++i) diff --git a/ort/cv/efficientdet.cpp b/ort/cv/efficientdet.cpp index 27eeab44..e643ee94 100644 --- a/ort/cv/efficientdet.cpp +++ b/ort/cv/efficientdet.cpp @@ -71,8 +71,16 @@ void EfficientDet::generate_anchors(const float target_height, const float targe float x1 = xv - anchor_size_x_2; // cx - aw/2 float y2 = yv + anchor_size_y_2; // cy + ah/2 float x2 = xv + anchor_size_x_2; // cx + aw/2 - +#ifdef LITE_WIN32 + EfficientDetAnchor anchor; + anchor.y1 = y1; + anchor.x1 = x1; + anchor.y2 = y2; + anchor.x2 = x2; + anchors_buffer.push_back(anchor); +#else anchors_buffer.push_back((EfficientDetAnchor) {y1, x1, y2, x2}); +#endif } // end ratios 3 } // end scale 3 } diff --git a/ort/cv/efficientdet_d7.cpp b/ort/cv/efficientdet_d7.cpp index 8517b22a..bceefee3 100644 --- a/ort/cv/efficientdet_d7.cpp +++ b/ort/cv/efficientdet_d7.cpp @@ -71,8 +71,16 @@ void EfficientDetD7::generate_anchors(const float target_height, const float tar float x1 = xv - anchor_size_x_2; // cx - aw/2 float y2 = yv + anchor_size_y_2; // cy + ah/2 float x2 = xv + anchor_size_x_2; // cx + aw/2 - +#ifdef LITE_WIN32 + EfficientDetD7Anchor anchor; + anchor.y1 = y1; + anchor.x1 = x1; + anchor.y2 = y2; + anchor.x2 = x2; + anchors_buffer.push_back(anchor); +#else anchors_buffer.push_back((EfficientDetD7Anchor) {y1, x1, y2, x2}); +#endif } // end ratios 3 } // end scale 3 } diff --git a/ort/cv/efficientdet_d8.cpp b/ort/cv/efficientdet_d8.cpp index 08c7e271..be66186f 100644 --- a/ort/cv/efficientdet_d8.cpp +++ b/ort/cv/efficientdet_d8.cpp @@ -70,8 +70,16 @@ void EfficientDetD8::generate_anchors(const float target_height, const float tar float x1 = xv - anchor_size_x_2; // cx - aw/2 float y2 = yv + anchor_size_y_2; // cy + ah/2 float x2 = xv + anchor_size_x_2; // cx + aw/2 - +#ifdef LITE_WIN32 + EfficientDetD8Anchor anchor; + anchor.y1 = y1; + anchor.x1 = x1; + anchor.y2 = y2; + anchor.x2 = x2; + anchors_buffer.push_back(anchor); +#else anchors_buffer.push_back((EfficientDetD8Anchor) {y1, x1, y2, x2}); +#endif } // end ratios 3 } // end scale 3 } diff --git a/ort/cv/nanodet.cpp b/ort/cv/nanodet.cpp index a2855dea..57d1db2a 100644 --- a/ort/cv/nanodet.cpp +++ b/ort/cv/nanodet.cpp @@ -97,7 +97,15 @@ void NanoDet::generate_points(unsigned int target_height, unsigned int target_wi { float grid0 = (float) g0 + 0.5f; float grid1 = (float) g1 + 0.5f; +#ifdef LITE_WIN32 + NanoCenterPoint point; + point.grid0 = grid0; + point.grid1 = grid1; + point.stride = (float) stride; + points.push_back(point); +#else points.push_back((NanoCenterPoint) {grid0, grid1, (float) stride}); +#endif } } center_points[stride] = points; diff --git a/ort/cv/nanodet_efficientnet_lite.cpp b/ort/cv/nanodet_efficientnet_lite.cpp index 0f54f6bf..f9bfbd72 100644 --- a/ort/cv/nanodet_efficientnet_lite.cpp +++ b/ort/cv/nanodet_efficientnet_lite.cpp @@ -97,7 +97,15 @@ void NanoDetEfficientNetLite::generate_points(unsigned int target_height, unsign { float grid0 = (float) g0 + 0.5f; float grid1 = (float) g1 + 0.5f; +#ifdef LITE_WIN32 + NanoLiteCenterPoint point; + point.grid0 = grid0; + point.grid1 = grid1; + point.stride = (float) stride; + points.push_back(point); +#else points.push_back((NanoLiteCenterPoint) {grid0, grid1, (float) stride}); +#endif } } center_points[stride] = points; diff --git a/ort/cv/yolox.cpp b/ort/cv/yolox.cpp index b007c042..011f5ed9 100644 --- a/ort/cv/yolox.cpp +++ b/ort/cv/yolox.cpp @@ -87,7 +87,15 @@ void YoloX::generate_anchors(const int target_height, { for (int g0 = 0; g0 < num_grid_w; ++g0) { +#ifdef LITE_WIN32 + YoloXAnchor anchor; + anchor.grid0 = g0; + anchor.grid1 = g1; + anchor.stride = stride; + anchors.push_back(anchor); +#else anchors.push_back((YoloXAnchor) {g0, g1, stride}); +#endif } } }