Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions detection_2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ project(detection_2d)

add_subdirectory(detection_2d_yolov8)
add_subdirectory(detection_2d_rt_detr)
add_subdirectory(detection_2d_yolo26)
41 changes: 41 additions & 0 deletions detection_2d/detection_2d_yolo26/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
53 changes: 53 additions & 0 deletions detection_2d/detection_2d_yolo26/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include <gtest/gtest.h>

#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<BaseDetectionModel> 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<std::string> input_blobs_name = {"images"};
const std::vector<std::string> 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<BaseDetectionModel> 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<std::string> input_blobs_name = {"images"};
const std::vector<std::string> 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();
49 changes: 49 additions & 0 deletions detection_2d/detection_2d_yolo26/eval/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
74 changes: 74 additions & 0 deletions detection_2d/detection_2d_yolo26/eval/eval_detection_2d_yolo26.cpp
Original file line number Diff line number Diff line change
@@ -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<std::string> input_blobs_name = {"images"};
const std::vector<std::string> 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<std::string> input_blobs_name = {"images"};
const std::vector<std::string> 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()
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include "deploy_core/base_detection.hpp"

namespace easy_deploy {

std::shared_ptr<BaseDetectionModel> CreateYolo26DetectionModel(
const std::shared_ptr<BaseInferCore> &infer_core,
const std::shared_ptr<IDetectionPreProcess> &preprocess_block,
const int input_height,
const int input_width,
const int input_channel,
const int cls_number,
const std::vector<std::string> &input_blobs_name = {"images"},
const std::vector<std::string> &output_blobs_name = {"labels", "boxes", "scores"});

std::shared_ptr<BaseDetection2DFactory> CreateYolo26DetectionModelFactory(
std::shared_ptr<BaseInferCoreFactory> infer_core_factory,
std::shared_ptr<BaseDetectionPreprocessFactory> preprocess_factory,
int input_height,
int input_width,
int input_channel,
int cls_number,
const std::vector<std::string> &input_blob_name,
const std::vector<std::string> &output_blob_name);

} // namespace easy_deploy
Loading