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
4 changes: 4 additions & 0 deletions detection_2d/detection_2d_rt_detr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ endif()
if (BUILD_BENCHMARK)
add_subdirectory(benchmark)
endif()

if (BUILD_EVAL)
add_subdirectory(eval)
endif()
49 changes: 49 additions & 0 deletions detection_2d/detection_2d_rt_detr/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_rt_detr.cpp
)

include_directories(
include
${OpenCV_INCLUDE_DIRS}
)

add_executable(eval_detection_2d_rt_detr ${source_file})

target_link_libraries(eval_detection_2d_rt_detr PUBLIC
${OpenCV_LIBS}
deploy_core
image_processing_utils
detection_2d_rt_detr
eval_utils
${platform_core_packages}
)

if(ENABLE_TENSORRT)
target_compile_definitions(eval_detection_2d_rt_detr PRIVATE ENABLE_TENSORRT)
endif()

if(ENABLE_RKNN)
target_compile_definitions(eval_detection_2d_rt_detr PRIVATE ENABLE_RKNN)
endif()

if(ENABLE_ORT)
target_compile_definitions(eval_detection_2d_rt_detr PRIVATE ENABLE_ORT)
endif()
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_rt_detr/rt_detr.hpp"

using namespace easy_deploy;

#ifdef ENABLE_TENSORRT

#include "trt_core/trt_core.hpp"

class EvalAccuracyRTDetrTensorRTFixture : public EvalAccuracyDetection2DFixture {
public:
SetUpReturnType SetUp() override
{
std::string model_path = "/workspace/models/rt_detr_v2_single_input.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 = {"labels", "boxes", "scores"};

auto infer_core = CreateTrtInferCore(model_path);
auto preprocess = CreateCudaDetPreProcess();

auto rt_detr_model =
CreateRTDetrDetectionModel(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 {rt_detr_model, coco_eval_dir_path, coco_annotations_path};
}
};

RegisterEvalAccuracyDetection2D(EvalAccuracyRTDetrTensorRTFixture);

#endif

#ifdef ENABLE_ORT

#include "ort_core/ort_core.hpp"

class EvalAccuracyRTDetrOnnxRuntimeFixture : public EvalAccuracyDetection2DFixture {
public:
SetUpReturnType SetUp() override
{
std::string model_path = "/workspace/models/rt_detr_v2_single_input.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 = {"labels", "boxes", "scores"};

auto infer_core = CreateOrtInferCore(model_path);
auto preprocess = CreateCpuDetPreProcess({0, 0, 0}, {255, 255, 255}, true, true);

auto rt_detr_model =
CreateRTDetrDetectionModel(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 {rt_detr_model, coco_eval_dir_path, coco_annotations_path};
}
};

RegisterEvalAccuracyDetection2D(EvalAccuracyRTDetrOnnxRuntimeFixture);

#endif

EVAL_MAIN()
4 changes: 4 additions & 0 deletions detection_2d/detection_2d_yolov8/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ endif()
if (BUILD_BENCHMARK)
add_subdirectory(benchmark)
endif()

if (BUILD_EVAL)
add_subdirectory(eval)
endif()
2 changes: 0 additions & 2 deletions detection_2d/detection_2d_yolov8/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ if(ENABLE_ORT)
list(APPEND platform_core_packages ort_core)
endif()

find_package(glog REQUIRED)
find_package(OpenCV REQUIRED)
find_package(benchmark REQUIRED)

Expand All @@ -31,7 +30,6 @@ add_executable(benchmark_detection_2d_yolov8 ${source_file})

target_link_libraries(benchmark_detection_2d_yolov8 PUBLIC
benchmark::benchmark
glog::glog
${OpenCV_LIBS}
deploy_core
image_processing_utils
Expand Down
49 changes: 49 additions & 0 deletions detection_2d/detection_2d_yolov8/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_yolov8.cpp
)

include_directories(
include
${OpenCV_INCLUDE_DIRS}
)

add_executable(eval_detection_2d_yolov8 ${source_file})

target_link_libraries(eval_detection_2d_yolov8 PUBLIC
${OpenCV_LIBS}
deploy_core
image_processing_utils
detection_2d_yolov8
eval_utils
${platform_core_packages}
)

if(ENABLE_TENSORRT)
target_compile_definitions(eval_detection_2d_yolov8 PRIVATE ENABLE_TENSORRT)
endif()

if(ENABLE_RKNN)
target_compile_definitions(eval_detection_2d_yolov8 PRIVATE ENABLE_RKNN)
endif()

if(ENABLE_ORT)
target_compile_definitions(eval_detection_2d_yolov8 PRIVATE ENABLE_ORT)
endif()
114 changes: 114 additions & 0 deletions detection_2d/detection_2d_yolov8/eval/eval_detection_2d_yolov8.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#include "eval_utils/detection_2d_eval_utils.hpp"
#include "detection_2d_util/detection_2d_util.hpp"
#include "detection_2d_yolov8/yolov8.hpp"

using namespace easy_deploy;

#ifdef ENABLE_TENSORRT

#include "trt_core/trt_core.hpp"

class EvalAccuracyYolov8TensorRTFixture : public EvalAccuracyDetection2DFixture {
public:
SetUpReturnType SetUp() override
{
std::string model_path = "/workspace/models/yolov8n.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 = CreateCudaDetPreProcess();
auto postprocess = CreateYolov8PostProcessCpuOrigin(input_height, input_width, cls_number);

auto yolov8_model =
CreateYolov8DetectionModel(infer_core, preprocess, postprocess, 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 {yolov8_model, coco_eval_dir_path, coco_annotations_path};
}
};

RegisterEvalAccuracyDetection2D(EvalAccuracyYolov8TensorRTFixture);

#endif

#ifdef ENABLE_ORT

#include "ort_core/ort_core.hpp"

class EvalAccuracyYolov8OnnxRuntimeFixture : public EvalAccuracyDetection2DFixture {
public:
SetUpReturnType SetUp() override
{
std::string model_path = "/workspace/models/yolov8n.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 postprocess = CreateYolov8PostProcessCpuOrigin(input_height, input_width, cls_number);

auto yolov8_model =
CreateYolov8DetectionModel(infer_core, preprocess, postprocess, 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 {yolov8_model, coco_eval_dir_path, coco_annotations_path};
}
};

RegisterEvalAccuracyDetection2D(EvalAccuracyYolov8OnnxRuntimeFixture);

#endif

#ifdef ENABLE_RKNN

#include "rknn_core/rknn_core.hpp"

class EvalAccuracyYolov8RknnFixture : public EvalAccuracyDetection2DFixture {
public:
SetUpReturnType SetUp() override
{
std::string model_path = "/workspace/models/yolov8n_divide_opset11.rknn";
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 = {"318", "onnx::ReduceSum_326", "331",
"338", "onnx::ReduceSum_346", "350",
"357", "onnx::ReduceSum_365", "369"};

auto infer_core = CreateRknnInferCore(model_path, {{"images", RknnInputTensorType::RK_UINT8}});
auto preprocess = CreateCpuDetPreProcess({0, 0, 0}, {1, 1, 1}, false, false);
auto postprocess = CreateYolov8PostProcessCpuDivide(input_height, input_width, cls_number);

auto yolov8_model =
CreateYolov8DetectionModel(infer_core, preprocess, postprocess, 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 {yolov8_model, coco_eval_dir_path, coco_annotations_path};
}
};

RegisterEvalAccuracyDetection2D(EvalAccuracyYolov8RknnFixture);

#endif

EVAL_MAIN()
2 changes: 1 addition & 1 deletion easy_deploy_tool