diff --git a/detection_2d/CMakeLists.txt b/detection_2d/CMakeLists.txt index 6e5361c..1ada916 100644 --- a/detection_2d/CMakeLists.txt +++ b/detection_2d/CMakeLists.txt @@ -4,3 +4,4 @@ project(detection_2d) add_subdirectory(detection_2d_yolov8) add_subdirectory(detection_2d_rt_detr) +add_subdirectory(detection_2d_yolo26) diff --git a/detection_2d/detection_2d_yolo26/CMakeLists.txt b/detection_2d/detection_2d_yolo26/CMakeLists.txt new file mode 100644 index 0000000..f794696 --- /dev/null +++ b/detection_2d/detection_2d_yolo26/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.8) +project(detection_2d_yolo26) + +add_compile_options(-std=c++17) +add_compile_options(-O3 -Wextra -Wdeprecated -fPIC) +set(CMAKE_CXX_STANDARD 17) + +find_package(OpenCV REQUIRED) + +include_directories( + include + ${OpenCV_INCLUDE_DIRS} +) + +set(source_file src/yolo26.cpp + src/yolo26_factory.cpp) + +add_library(${PROJECT_NAME} SHARED ${source_file}) + +target_link_libraries(${PROJECT_NAME} PUBLIC + ${OpenCV_LIBS} + deploy_core + common_utils +) + +install(TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION lib) + +target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include) + +if (BUILD_TESTING) + add_subdirectory(test) +endif() + +if (BUILD_BENCHMARK) + add_subdirectory(benchmark) +endif() + +if (BUILD_EVAL) + add_subdirectory(eval) +endif() diff --git a/detection_2d/detection_2d_yolo26/benchmark/CMakeLists.txt b/detection_2d/detection_2d_yolo26/benchmark/CMakeLists.txt new file mode 100644 index 0000000..786d033 --- /dev/null +++ b/detection_2d/detection_2d_yolo26/benchmark/CMakeLists.txt @@ -0,0 +1,53 @@ +add_compile_options(-std=c++17) +add_compile_options(-O3 -Wextra -Wdeprecated -fPIC) +set(CMAKE_CXX_STANDARD 17) + +if(ENABLE_TENSORRT) + list(APPEND platform_core_packages trt_core) +endif() + +if(ENABLE_RKNN) + list(APPEND platform_core_packages rknn_core) +endif() + +if(ENABLE_ORT) + list(APPEND platform_core_packages ort_core) +endif() + +find_package(glog REQUIRED) +find_package(OpenCV REQUIRED) +find_package(benchmark REQUIRED) + +set(source_file + benchmark_detection_2d_yolo26.cpp +) + +include_directories( + include + ${OpenCV_INCLUDE_DIRS} +) + +add_executable(benchmark_detection_2d_yolo26 ${source_file}) + +target_link_libraries(benchmark_detection_2d_yolo26 PUBLIC + benchmark::benchmark + glog::glog + ${OpenCV_LIBS} + deploy_core + image_processing_utils + detection_2d_yolo26 + benchmark_utils + ${platform_core_packages} +) + +if(ENABLE_TENSORRT) + target_compile_definitions(benchmark_detection_2d_yolo26 PRIVATE ENABLE_TENSORRT) +endif() + +if(ENABLE_RKNN) + target_compile_definitions(benchmark_detection_2d_yolo26 PRIVATE ENABLE_RKNN) +endif() + +if(ENABLE_ORT) + target_compile_definitions(benchmark_detection_2d_yolo26 PRIVATE ENABLE_ORT) +endif() diff --git a/detection_2d/detection_2d_yolo26/benchmark/benchmark_detection_2d_yolo26.cpp b/detection_2d/detection_2d_yolo26/benchmark/benchmark_detection_2d_yolo26.cpp new file mode 100644 index 0000000..3fd7d54 --- /dev/null +++ b/detection_2d/detection_2d_yolo26/benchmark/benchmark_detection_2d_yolo26.cpp @@ -0,0 +1,81 @@ +#include + +#include "detection_2d_util/detection_2d_util.hpp" +#include "detection_2d_yolo26/yolo26.hpp" +#include "benchmark_utils/detection_2d_benchmark_utils.hpp" + +using namespace easy_deploy; + +#ifdef ENABLE_TENSORRT + +#include "trt_core/trt_core.hpp" + +std::shared_ptr CreateYolo26TensorRTModel() +{ + std::string model_path = "/workspace/models/yolo26n.engine"; + const int input_height = 640; + const int input_width = 640; + const int input_channels = 3; + const int cls_number = 80; + const std::vector input_blobs_name = {"images"}; + const std::vector output_blobs_name = {"output0"}; + + auto infer_core = CreateTrtInferCore(model_path); + auto preprocess = CreateCpuDetPreProcess({0, 0, 0}, {255, 255, 255}, true, true); + + auto yolo26_model = + CreateYolo26DetectionModel(infer_core, preprocess, input_height, input_width, input_channels, + cls_number, input_blobs_name, output_blobs_name); + return yolo26_model; +} + +static void benchmark_detection_2d_yolo26_tensorrt_sync(benchmark::State &state) +{ + benchmark_detection_2d_sync(state, CreateYolo26TensorRTModel()); +} +static void benchmark_detection_2d_yolo26_tensorrt_async(benchmark::State &state) +{ + benchmark_detection_2d_async(state, CreateYolo26TensorRTModel()); +} +BENCHMARK(benchmark_detection_2d_yolo26_tensorrt_sync)->Arg(500)->UseRealTime(); +BENCHMARK(benchmark_detection_2d_yolo26_tensorrt_async)->Arg(500)->UseRealTime(); + +#endif + +#ifdef ENABLE_ORT + +#include "ort_core/ort_core.hpp" + +std::shared_ptr CreateYolo26OnnxRuntimeModel() +{ + std::string model_path = "/workspace/models/yolo26n.onnx"; + const int input_height = 640; + const int input_width = 640; + const int input_channels = 3; + const int cls_number = 80; + const std::vector input_blobs_name = {"images"}; + const std::vector output_blobs_name = {"output0"}; + + auto infer_core = CreateOrtInferCore(model_path); + auto preprocess = CreateCpuDetPreProcess({0, 0, 0}, {255, 255, 255}, true, true); + + auto yolo26_model = + CreateYolo26DetectionModel(infer_core, preprocess, input_height, input_width, input_channels, + cls_number, input_blobs_name, output_blobs_name); + return yolo26_model; +} + +static void benchmark_detection_2d_yolo26_onnxruntime_sync(benchmark::State &state) +{ + benchmark_detection_2d_sync(state, CreateYolo26OnnxRuntimeModel()); +} +static void benchmark_detection_2d_yolo26_onnxruntime_async(benchmark::State &state) +{ + benchmark_detection_2d_async(state, CreateYolo26OnnxRuntimeModel()); +} +BENCHMARK(benchmark_detection_2d_yolo26_onnxruntime_sync)->Arg(100)->UseRealTime(); +BENCHMARK(benchmark_detection_2d_yolo26_onnxruntime_async)->Arg(100)->UseRealTime(); + +#endif + +BENCHMARK_MAIN(); diff --git a/detection_2d/detection_2d_yolo26/eval/CMakeLists.txt b/detection_2d/detection_2d_yolo26/eval/CMakeLists.txt new file mode 100644 index 0000000..78f8412 --- /dev/null +++ b/detection_2d/detection_2d_yolo26/eval/CMakeLists.txt @@ -0,0 +1,49 @@ +add_compile_options(-std=c++17) +add_compile_options(-O3 -Wextra -Wdeprecated -fPIC) +set(CMAKE_CXX_STANDARD 17) + +if(ENABLE_TENSORRT) + list(APPEND platform_core_packages trt_core) +endif() + +if(ENABLE_RKNN) + list(APPEND platform_core_packages rknn_core) +endif() + +if(ENABLE_ORT) + list(APPEND platform_core_packages ort_core) +endif() + +find_package(OpenCV REQUIRED) + +set(source_file + eval_detection_2d_yolo26.cpp +) + +include_directories( + include + ${OpenCV_INCLUDE_DIRS} +) + +add_executable(eval_detection_2d_yolo26 ${source_file}) + +target_link_libraries(eval_detection_2d_yolo26 PUBLIC + ${OpenCV_LIBS} + deploy_core + image_processing_utils + detection_2d_yolo26 + eval_utils + ${platform_core_packages} +) + +if(ENABLE_TENSORRT) + target_compile_definitions(eval_detection_2d_yolo26 PRIVATE ENABLE_TENSORRT) +endif() + +if(ENABLE_RKNN) + target_compile_definitions(eval_detection_2d_yolo26 PRIVATE ENABLE_RKNN) +endif() + +if(ENABLE_ORT) + target_compile_definitions(eval_detection_2d_yolo26 PRIVATE ENABLE_ORT) +endif() diff --git a/detection_2d/detection_2d_yolo26/eval/eval_detection_2d_yolo26.cpp b/detection_2d/detection_2d_yolo26/eval/eval_detection_2d_yolo26.cpp new file mode 100644 index 0000000..db8eb75 --- /dev/null +++ b/detection_2d/detection_2d_yolo26/eval/eval_detection_2d_yolo26.cpp @@ -0,0 +1,74 @@ +#include "eval_utils/detection_2d_eval_utils.hpp" +#include "detection_2d_util/detection_2d_util.hpp" +#include "detection_2d_yolo26/yolo26.hpp" + +using namespace easy_deploy; + +#ifdef ENABLE_TENSORRT + +#include "trt_core/trt_core.hpp" + +class EvalAccuracyYolo26TensorRTFixture : public EvalAccuracyDetection2DFixture { +public: + SetUpReturnType SetUp() override + { + std::string model_path = "/workspace/models/yolo26n.engine"; + const int input_height = 640; + const int input_width = 640; + const int input_channels = 3; + const int cls_number = 80; + const std::vector input_blobs_name = {"images"}; + const std::vector output_blobs_name = {"output0"}; + + auto infer_core = CreateTrtInferCore(model_path); + auto preprocess = CreateCpuDetPreProcess({0, 0, 0}, {255, 255, 255}, true, true); + + auto yolo26_model = + CreateYolo26DetectionModel(infer_core, preprocess, input_height, input_width, + input_channels, cls_number, input_blobs_name, output_blobs_name); + const std::string coco_eval_dir_path = "/workspace/test_data/coco2017/coco2017_val"; + const std::string coco_annotations_path = + "/workspace/test_data/coco2017/coco2017_annotations/instances_val2017.json"; + return {yolo26_model, coco_eval_dir_path, coco_annotations_path}; + } +}; + +RegisterEvalAccuracyDetection2D(EvalAccuracyYolo26TensorRTFixture); + +#endif + +#ifdef ENABLE_ORT + +#include "ort_core/ort_core.hpp" + +class EvalAccuracyYolo26OnnxRuntimeFixture : public EvalAccuracyDetection2DFixture { +public: + SetUpReturnType SetUp() override + { + std::string model_path = "/workspace/models/yolo26n.onnx"; + const int input_height = 640; + const int input_width = 640; + const int input_channels = 3; + const int cls_number = 80; + const std::vector input_blobs_name = {"images"}; + const std::vector output_blobs_name = {"output0"}; + + auto infer_core = CreateOrtInferCore(model_path); + auto preprocess = CreateCpuDetPreProcess({0, 0, 0}, {255, 255, 255}, true, true); + + auto yolo26_model = + CreateYolo26DetectionModel(infer_core, preprocess, input_height, input_width, + input_channels, cls_number, input_blobs_name, output_blobs_name); + + const std::string coco_eval_dir_path = "/workspace/test_data/coco2017/coco2017_val"; + const std::string coco_annotations_path = + "/workspace/test_data/coco2017/coco2017_annotations/instances_val2017.json"; + return {yolo26_model, coco_eval_dir_path, coco_annotations_path}; + } +}; + +RegisterEvalAccuracyDetection2D(EvalAccuracyYolo26OnnxRuntimeFixture); + +#endif + +EVAL_MAIN() diff --git a/detection_2d/detection_2d_yolo26/include/detection_2d_yolo26/yolo26.hpp b/detection_2d/detection_2d_yolo26/include/detection_2d_yolo26/yolo26.hpp new file mode 100644 index 0000000..f36472d --- /dev/null +++ b/detection_2d/detection_2d_yolo26/include/detection_2d_yolo26/yolo26.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "deploy_core/base_detection.hpp" + +namespace easy_deploy { + +std::shared_ptr CreateYolo26DetectionModel( + const std::shared_ptr &infer_core, + const std::shared_ptr &preprocess_block, + const int input_height, + const int input_width, + const int input_channel, + const int cls_number, + const std::vector &input_blobs_name = {"images"}, + const std::vector &output_blobs_name = {"labels", "boxes", "scores"}); + +std::shared_ptr CreateYolo26DetectionModelFactory( + std::shared_ptr infer_core_factory, + std::shared_ptr preprocess_factory, + int input_height, + int input_width, + int input_channel, + int cls_number, + const std::vector &input_blob_name, + const std::vector &output_blob_name); + +} // namespace easy_deploy diff --git a/detection_2d/detection_2d_yolo26/src/yolo26.cpp b/detection_2d/detection_2d_yolo26/src/yolo26.cpp new file mode 100644 index 0000000..0929e75 --- /dev/null +++ b/detection_2d/detection_2d_yolo26/src/yolo26.cpp @@ -0,0 +1,150 @@ +#include "detection_2d_yolo26/yolo26.hpp" + +namespace easy_deploy { + +class Yolo26Detection : public BaseDetectionModel { +public: + Yolo26Detection(const std::shared_ptr &infer_core, + const std::shared_ptr &preprocess_block, + const int input_height, + const int input_width, + const int input_channel, + const int cls_number, + const std::vector &input_blobs_name, + const std::vector &output_blobs_name); + + ~Yolo26Detection() = default; + +private: + bool PreProcess(std::shared_ptr pipeline_unit) override; + + bool PostProcess(std::shared_ptr pipeline_unit) override; + +private: + const std::vector input_blobs_name_; + const std::vector output_blobs_name_; + const int input_height_; + const int input_width_; + const int input_channel_; + const int cls_number_; + + const std::shared_ptr infer_core_; + std::shared_ptr preprocess_block_; +}; + +Yolo26Detection::Yolo26Detection(const std::shared_ptr &infer_core, + const std::shared_ptr &preprocess_block, + const int input_height, + const int input_width, + const int input_channel, + const int cls_number, + const std::vector &input_blobs_name, + const std::vector &output_blobs_name) + : BaseDetectionModel(infer_core), + input_blobs_name_(input_blobs_name), + output_blobs_name_(output_blobs_name), + input_height_(input_height), + input_width_(input_width), + input_channel_(input_channel), + cls_number_(cls_number), + infer_core_(infer_core), + preprocess_block_(preprocess_block) +{ + // 创建并获取一个缓存句柄,用于校验模型与算法的一致性 + auto blobs_tensor = infer_core_->AllocBlobsBuffer(); + if (blobs_tensor->Size() != input_blobs_name_.size() + output_blobs_name_.size()) + { + LOG_ERROR("[Yolo26Detection] Infer core should has {%ld} blobs, but got {%ld} blobs", + input_blobs_name_.size() + output_blobs_name_.size(), blobs_tensor->Size()); + throw std::runtime_error( + "[Yolo26Detection] Construction Failed!!! Got invalid blobs_num size!!!"); + } + + for (const std::string &input_blob_name : input_blobs_name) + { + blobs_tensor->GetTensor(input_blob_name); + } + + for (const std::string &output_blob_name : output_blobs_name) + { + blobs_tensor->GetTensor(output_blob_name); + } +} + +bool Yolo26Detection::PreProcess(std::shared_ptr _package) +{ + auto package = std::dynamic_pointer_cast(_package); + CHECK_STATE(package != nullptr, + "[Yolo26Detection] PreProcess the `_package` instance does not belong to " + "`DetectionPipelinePackage`"); + + const auto &blobs_tensor = package->GetInferBuffer(); + + float scale = preprocess_block_->Preprocess(package->input_image_data, + blobs_tensor->GetTensor(input_blobs_name_[0]), + input_height_, input_width_); + + package->transform_scale = scale; + return true; +} + +bool Yolo26Detection::PostProcess(std::shared_ptr _package) +{ + auto package = std::dynamic_pointer_cast(_package); + CHECK_STATE(package != nullptr, + "[Yolo26Detection] PostProcess the `_package` instance does not belong to " + "`DetectionPipelinePackage`"); + + const auto &blobs_tensor = package->GetInferBuffer(); + + // Yolo26Detection outputs: (1, 300, 6): conf(1), label(1), box(4) + + float *output_ptr = blobs_tensor->GetTensor(output_blobs_name_[0])->Cast(); + + const int CANDIDATES_NUM = 300; + const float conf_thresh = package->conf_thresh; + const float transf_scale = package->transform_scale; + + std::vector valid_boxes; + for (int i = 0; i < CANDIDATES_NUM; ++i) + { + const int offset = 6 * i; + if (output_ptr[offset + 4] >= conf_thresh) + { + float x0 = output_ptr[offset + 0]; + float y0 = output_ptr[offset + 1]; + float x1 = output_ptr[offset + 2]; + float y1 = output_ptr[offset + 3]; + + BBox2D box; + box.x = (x0 + x1) / 2 / transf_scale; + box.y = (y0 + y1) / 2 / transf_scale; + box.w = (x1 - x0) / transf_scale; + box.h = (y1 - y0) / transf_scale; + box.cls = static_cast(output_ptr[offset + 5]); + box.conf = output_ptr[offset + 4]; + valid_boxes.push_back(box); + } + } + + package->results = std::move(valid_boxes); + + return true; +} + +std::shared_ptr CreateYolo26DetectionModel( + const std::shared_ptr &infer_core, + const std::shared_ptr &preprocess_block, + const int input_height, + const int input_width, + const int input_channel, + const int cls_number, + const std::vector &input_blobs_name, + const std::vector &output_blobs_name) +{ + return std::make_shared(infer_core, preprocess_block, input_height, input_width, + input_channel, cls_number, input_blobs_name, + output_blobs_name); +} + +} // namespace easy_deploy diff --git a/detection_2d/detection_2d_yolo26/src/yolo26_factory.cpp b/detection_2d/detection_2d_yolo26/src/yolo26_factory.cpp new file mode 100644 index 0000000..30241a8 --- /dev/null +++ b/detection_2d/detection_2d_yolo26/src/yolo26_factory.cpp @@ -0,0 +1,60 @@ +#include "detection_2d_yolo26/yolo26.hpp" + +namespace easy_deploy { + +struct Yolo26Params { + std::shared_ptr infer_core_factory; + std::shared_ptr preprocess_factory; + int input_height; + int input_width; + int input_channel; + int cls_number; + std::vector input_blob_name; + std::vector output_blob_name; +}; + +class Detection2DYolo26Factory : public BaseDetection2DFactory { +public: + Detection2DYolo26Factory(const Yolo26Params ¶ms) : params_(params) + {} + std::shared_ptr Create() override + { + return CreateYolo26DetectionModel( + params_.infer_core_factory->Create(), params_.preprocess_factory->Create(), + params_.input_height, params_.input_width, params_.input_channel, params_.cls_number, + params_.input_blob_name, params_.output_blob_name); + } + +private: + Yolo26Params params_; +}; + +std::shared_ptr CreateYolo26DetectionModelFactory( + std::shared_ptr infer_core_factory, + std::shared_ptr preprocess_factory, + int input_height, + int input_width, + int input_channel, + int cls_number, + const std::vector &input_blob_name, + const std::vector &output_blob_name) +{ + if (infer_core_factory == nullptr || preprocess_factory == nullptr) + { + throw std::invalid_argument("[CreateYolo26DetectionModelFactory] Got invalid input arguments!"); + } + + Yolo26Params params; + params.infer_core_factory = infer_core_factory; + params.preprocess_factory = preprocess_factory; + params.input_height = input_height; + params.input_width = input_width; + params.input_channel = input_channel; + params.cls_number = cls_number; + params.input_blob_name = input_blob_name; + params.output_blob_name = output_blob_name; + + return std::make_shared(params); +} + +} // namespace easy_deploy diff --git a/detection_2d/detection_2d_yolo26/test/CMakeLists.txt b/detection_2d/detection_2d_yolo26/test/CMakeLists.txt new file mode 100644 index 0000000..09d7531 --- /dev/null +++ b/detection_2d/detection_2d_yolo26/test/CMakeLists.txt @@ -0,0 +1,55 @@ +add_compile_options(-std=c++17) +add_compile_options(-O3 -Wextra -Wdeprecated -fPIC) +set(CMAKE_CXX_STANDARD 17) + +if(ENABLE_TENSORRT) + list(APPEND platform_core_packages trt_core) +endif() + +if(ENABLE_RKNN) + list(APPEND platform_core_packages rknn_core) +endif() + +if(ENABLE_ORT) + list(APPEND platform_core_packages ort_core) +endif() + +find_package(GTest REQUIRED) +find_package(glog REQUIRED) +find_package(OpenCV REQUIRED) + +set(source_file + test_detection_2d_yolo26.cpp +) + +include_directories( + include + ${OpenCV_INCLUDE_DIRS} +) + +add_executable(test_detection_2d_yolo26 ${source_file}) + +target_link_libraries(test_detection_2d_yolo26 PUBLIC + GTest::gtest_main + glog::glog + ${OpenCV_LIBS} + deploy_core + image_processing_utils + detection_2d_yolo26 + test_utils + ${platform_core_packages} +) + +if(ENABLE_TENSORRT) + target_compile_definitions(test_detection_2d_yolo26 PRIVATE ENABLE_TENSORRT) +endif() + +if(ENABLE_RKNN) + target_compile_definitions(test_detection_2d_yolo26 PRIVATE ENABLE_RKNN) +endif() + +if(ENABLE_ORT) + target_compile_definitions(test_detection_2d_yolo26 PRIVATE ENABLE_ORT) +endif() + +gtest_discover_tests(test_detection_2d_yolo26) diff --git a/detection_2d/detection_2d_yolo26/test/test_detection_2d_yolo26.cpp b/detection_2d/detection_2d_yolo26/test/test_detection_2d_yolo26.cpp new file mode 100644 index 0000000..2c580a5 --- /dev/null +++ b/detection_2d/detection_2d_yolo26/test/test_detection_2d_yolo26.cpp @@ -0,0 +1,98 @@ +#include + +#include "detection_2d_util/detection_2d_util.hpp" +#include "detection_2d_yolo26/yolo26.hpp" +#include "test_utils/detection_2d_test_utils.hpp" + +using namespace easy_deploy; + +#define GEN_TEST_CASES(Tag, FixtureClass) \ + TEST_F(FixtureClass, test_yolo26_##Tag##_correctness) \ + { \ + test_detection_2d_algorithm_correctness(yolo26_model_, test_image_path_, conf_threshold_, \ + expected_obj_num_, test_visual_result_save_path_); \ + } \ + TEST_F(FixtureClass, test_yolo26_##Tag##_async_correctness) \ + { \ + test_detection_2d_algorithm_async_correctness(yolo26_model_, test_image_path_, \ + conf_threshold_, expected_obj_num_, \ + test_visual_result_save_path_); \ + } + +class BaseYolo26Fixture : public testing::Test { +protected: + std::shared_ptr yolo26_model_; + + std::string test_image_path_; + std::string test_visual_result_save_path_; + float conf_threshold_; + size_t expected_obj_num_; +}; + +#ifdef ENABLE_TENSORRT + +#include "trt_core/trt_core.hpp" + +class Yolo26_TensorRT_Fixture : public BaseYolo26Fixture { +public: + void SetUp() override + { + std::string model_path = "/workspace/models/yolo26n.engine"; + const int input_height = 640; + const int input_width = 640; + const int input_channels = 3; + const int cls_number = 80; + const std::vector input_blobs_name = {"images"}; + const std::vector output_blobs_name = {"output0"}; + + auto infer_core = CreateTrtInferCore(model_path); + auto preprocess = CreateCpuDetPreProcess({0, 0, 0}, {255, 255, 255}, true, true); + + yolo26_model_ = + CreateYolo26DetectionModel(infer_core, preprocess, input_height, input_width, + input_channels, cls_number, input_blobs_name, output_blobs_name); + + test_image_path_ = "/workspace/test_data/persons.jpg"; + test_visual_result_save_path_ = "/workspace/test_data/yolo26_tensorrt_test_result.jpg"; + conf_threshold_ = 0.4; + expected_obj_num_ = 9ul; + } +}; + +GEN_TEST_CASES(tensorrt, Yolo26_TensorRT_Fixture); + +#endif + +#ifdef ENABLE_ORT + +#include "ort_core/ort_core.hpp" + +class Yolo26_OnnxRuntime_Fixture : public BaseYolo26Fixture { +public: + void SetUp() override + { + std::string model_path = "/workspace/models/yolo26n.onnx"; + const int input_height = 640; + const int input_width = 640; + const int input_channels = 3; + const int cls_number = 80; + const std::vector input_blobs_name = {"images"}; + const std::vector output_blobs_name = {"output0"}; + + auto infer_core = CreateOrtInferCore(model_path); + auto preprocess = CreateCpuDetPreProcess({0, 0, 0}, {255, 255, 255}, true, true); + + yolo26_model_ = + CreateYolo26DetectionModel(infer_core, preprocess, input_height, input_width, + input_channels, cls_number, input_blobs_name, output_blobs_name); + + test_image_path_ = "/workspace/test_data/persons.jpg"; + test_visual_result_save_path_ = "/workspace/test_data/yolo26_onnxruntime_test_result.jpg"; + conf_threshold_ = 0.4; + expected_obj_num_ = 9ul; + } +}; + +GEN_TEST_CASES(onnxruntime, Yolo26_OnnxRuntime_Fixture); + +#endif diff --git a/tools/cvt_onnx2trt_all.sh b/tools/cvt_onnx2trt_all.sh index 928e6ef..95569c9 100644 --- a/tools/cvt_onnx2trt_all.sh +++ b/tools/cvt_onnx2trt_all.sh @@ -4,6 +4,10 @@ echo "Converting yolov8 ..." --saveEngine=/workspace/models/yolov8n.engine \ --fp16 +echo "Converting yolo26 ..." +/usr/src/tensorrt/bin/trtexec --onnx=/workspace/models/yolo26n.onnx \ + --saveEngine=/workspace/models/yolo26n.engine + echo "Converting rt_detr_v2 ..." /usr/src/tensorrt/bin/trtexec --onnx=/workspace/models/rt_detr_v2_single_input.onnx \ --saveEngine=/workspace/models/rt_detr_v2_single_input.engine