Skip to content

Commit aeb2d9e

Browse files
authored
Refactor: Adopt easy_deploy_tool update (#11)
* refactor: Adopt changes in EasyDeployTool Signed-off-by: zz990099 <771647586@qq.com> * Update easy_deploy_tool submodule Signed-off-by: zz990099 <771647586@qq.com> --------- Signed-off-by: zz990099 <771647586@qq.com>
1 parent 179a38f commit aeb2d9e

File tree

22 files changed

+312
-387
lines changed

22 files changed

+312
-387
lines changed

detection_2d/detection_2d_rt_detr/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ add_compile_options(-O3 -Wextra -Wdeprecated -fPIC)
66
set(CMAKE_CXX_STANDARD 17)
77

88
find_package(OpenCV REQUIRED)
9-
find_package(glog REQUIRED)
109

1110
include_directories(
1211
include
@@ -19,9 +18,9 @@ set(source_file src/rt_detr.cpp
1918
add_library(${PROJECT_NAME} SHARED ${source_file})
2019

2120
target_link_libraries(${PROJECT_NAME} PUBLIC
22-
glog::glog
2321
${OpenCV_LIBS}
2422
deploy_core
23+
common_utils
2524
)
2625

2726
install(TARGETS ${PROJECT_NAME}

detection_2d/detection_2d_rt_detr/benchmark/benchmark_detection_2d_rt_detr.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#include <gtest/gtest.h>
22

3-
#include "detection_2d_util/detection_2d_util.h"
4-
#include "detection_2d_rt_detr/rt_detr.h"
3+
#include "detection_2d_util/detection_2d_util.hpp"
4+
#include "detection_2d_rt_detr/rt_detr.hpp"
55
#include "benchmark_utils/detection_2d_benchmark_utils.hpp"
66

7-
using namespace inference_core;
8-
using namespace detection_2d;
9-
using namespace benchmark_utils;
7+
using namespace easy_deploy;
108

119
#ifdef ENABLE_TENSORRT
1210

13-
#include "trt_core/trt_core.h"
11+
#include "trt_core/trt_core.hpp"
1412

1513
std::shared_ptr<BaseDetectionModel> CreateRTDetrTensorRTModel()
1614
{
@@ -46,7 +44,7 @@ BENCHMARK(benchmark_detection_2d_rt_detr_tensorrt_async)->Arg(500)->UseRealTime(
4644

4745
#ifdef ENABLE_ORT
4846

49-
#include "ort_core/ort_core.h"
47+
#include "ort_core/ort_core.hpp"
5048

5149
std::shared_ptr<BaseDetectionModel> CreateRTDetrOnnxRuntimeModel()
5250
{

detection_2d/detection_2d_rt_detr/include/detection_2d_rt_detr/rt_detr.h

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
3+
#include "deploy_core/base_detection.hpp"
4+
5+
namespace easy_deploy {
6+
7+
std::shared_ptr<BaseDetectionModel> CreateRTDetrDetectionModel(
8+
const std::shared_ptr<BaseInferCore> &infer_core,
9+
const std::shared_ptr<IDetectionPreProcess> &preprocess_block,
10+
const int input_height,
11+
const int input_width,
12+
const int input_channel,
13+
const int cls_number,
14+
const std::vector<std::string> &input_blobs_name = {"images"},
15+
const std::vector<std::string> &output_blobs_name = {"labels", "boxes", "scores"});
16+
17+
std::shared_ptr<BaseDetection2DFactory> CreateRTDetrDetectionModelFactory(
18+
std::shared_ptr<BaseInferCoreFactory> infer_core_factory,
19+
std::shared_ptr<BaseDetectionPreprocessFactory> preprocess_factory,
20+
int input_height,
21+
int input_width,
22+
int input_channel,
23+
int cls_number,
24+
const std::vector<std::string> &input_blob_name,
25+
const std::vector<std::string> &output_blob_name);
26+
27+
} // namespace easy_deploy

detection_2d/detection_2d_rt_detr/src/rt_detr.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
#include "detection_2d_rt_detr/rt_detr.h"
1+
#include "detection_2d_rt_detr/rt_detr.hpp"
22

3-
namespace detection_2d {
3+
namespace easy_deploy {
44

55
class RTDetrDetection : public BaseDetectionModel {
66
public:
7-
RTDetrDetection(const std::shared_ptr<inference_core::BaseInferCore> &infer_core,
8-
const std::shared_ptr<IDetectionPreProcess> &preprocess_block,
9-
const int input_height,
10-
const int input_width,
11-
const int input_channel,
12-
const int cls_number,
13-
const std::vector<std::string> &input_blobs_name,
14-
const std::vector<std::string> &output_blobs_name);
7+
RTDetrDetection(const std::shared_ptr<BaseInferCore> &infer_core,
8+
const std::shared_ptr<IDetectionPreProcess> &preprocess_block,
9+
const int input_height,
10+
const int input_width,
11+
const int input_channel,
12+
const int cls_number,
13+
const std::vector<std::string> &input_blobs_name,
14+
const std::vector<std::string> &output_blobs_name);
1515

1616
~RTDetrDetection() = default;
1717

1818
private:
19-
bool PreProcess(std::shared_ptr<async_pipeline::IPipelinePackage> pipeline_unit) override;
19+
bool PreProcess(std::shared_ptr<IPipelinePackage> pipeline_unit) override;
2020

21-
bool PostProcess(std::shared_ptr<async_pipeline::IPipelinePackage> pipeline_unit) override;
21+
bool PostProcess(std::shared_ptr<IPipelinePackage> pipeline_unit) override;
2222

2323
private:
2424
const std::vector<std::string> input_blobs_name_;
@@ -28,11 +28,11 @@ class RTDetrDetection : public BaseDetectionModel {
2828
const int input_channel_;
2929
const int cls_number_;
3030

31-
const std::shared_ptr<inference_core::BaseInferCore> infer_core_;
32-
std::shared_ptr<IDetectionPreProcess> preprocess_block_;
31+
const std::shared_ptr<BaseInferCore> infer_core_;
32+
std::shared_ptr<IDetectionPreProcess> preprocess_block_;
3333
};
3434

35-
RTDetrDetection::RTDetrDetection(const std::shared_ptr<inference_core::BaseInferCore> &infer_core,
35+
RTDetrDetection::RTDetrDetection(const std::shared_ptr<BaseInferCore> &infer_core,
3636
const std::shared_ptr<IDetectionPreProcess> &preprocess_block,
3737
const int input_height,
3838
const int input_width,
@@ -54,9 +54,8 @@ RTDetrDetection::RTDetrDetection(const std::shared_ptr<inference_core::BaseInfer
5454
auto blobs_tensor = infer_core_->AllocBlobsBuffer();
5555
if (blobs_tensor->Size() != input_blobs_name_.size() + output_blobs_name_.size())
5656
{
57-
LOG(ERROR) << "[RTDetrDetection] Infer core should has {"
58-
<< input_blobs_name_.size() + output_blobs_name_.size() << "} blobs !"
59-
<< " but got " << blobs_tensor->Size() << " blobs";
57+
LOG_ERROR("[RTDetrDetection] Infer core should has {%ld} blobs, but got {%ld} blobs",
58+
input_blobs_name_.size() + output_blobs_name_.size(), blobs_tensor->Size());
6059
throw std::runtime_error(
6160
"[RTDetrDetection] Construction Failed!!! Got invalid blobs_num size!!!");
6261
}
@@ -72,7 +71,7 @@ RTDetrDetection::RTDetrDetection(const std::shared_ptr<inference_core::BaseInfer
7271
}
7372
}
7473

75-
bool RTDetrDetection::PreProcess(std::shared_ptr<async_pipeline::IPipelinePackage> _package)
74+
bool RTDetrDetection::PreProcess(std::shared_ptr<IPipelinePackage> _package)
7675
{
7776
auto package = std::dynamic_pointer_cast<DetectionPipelinePackage>(_package);
7877
CHECK_STATE(package != nullptr,
@@ -89,7 +88,7 @@ bool RTDetrDetection::PreProcess(std::shared_ptr<async_pipeline::IPipelinePackag
8988
return true;
9089
}
9190

92-
bool RTDetrDetection::PostProcess(std::shared_ptr<async_pipeline::IPipelinePackage> _package)
91+
bool RTDetrDetection::PostProcess(std::shared_ptr<IPipelinePackage> _package)
9392
{
9493
auto package = std::dynamic_pointer_cast<DetectionPipelinePackage>(_package);
9594
CHECK_STATE(package != nullptr,
@@ -135,18 +134,18 @@ bool RTDetrDetection::PostProcess(std::shared_ptr<async_pipeline::IPipelinePacka
135134
}
136135

137136
std::shared_ptr<BaseDetectionModel> CreateRTDetrDetectionModel(
138-
const std::shared_ptr<inference_core::BaseInferCore> &infer_core,
139-
const std::shared_ptr<IDetectionPreProcess> &preprocess_block,
140-
const int input_height,
141-
const int input_width,
142-
const int input_channel,
143-
const int cls_number,
144-
const std::vector<std::string> &input_blobs_name,
145-
const std::vector<std::string> &output_blobs_name)
137+
const std::shared_ptr<BaseInferCore> &infer_core,
138+
const std::shared_ptr<IDetectionPreProcess> &preprocess_block,
139+
const int input_height,
140+
const int input_width,
141+
const int input_channel,
142+
const int cls_number,
143+
const std::vector<std::string> &input_blobs_name,
144+
const std::vector<std::string> &output_blobs_name)
146145
{
147146
return std::make_shared<RTDetrDetection>(infer_core, preprocess_block, input_height, input_width,
148147
input_channel, cls_number, input_blobs_name,
149148
output_blobs_name);
150149
}
151150

152-
} // namespace detection_2d
151+
} // namespace easy_deploy
Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
1-
/*
2-
* @Description:
3-
* @Author: Teddywesside 18852056629@163.com
4-
* @Date: 2024-12-02 19:22:45
5-
* @LastEditTime: 2024-12-02 19:33:03
6-
* @FilePath: /easy_deploy/detection_2d/detection_2d_rt_detr/src/rt_detr_factory.cpp
7-
*/
8-
#include "detection_2d_rt_detr/rt_detr.h"
1+
#include "detection_2d_rt_detr/rt_detr.hpp"
92

10-
namespace detection_2d {
3+
namespace easy_deploy {
114

125
struct RTDetrParams {
13-
std::shared_ptr<inference_core::BaseInferCoreFactory> infer_core_factory;
14-
std::shared_ptr<detection_2d::BaseDetectionPreprocessFactory> preprocess_factory;
15-
int input_height;
16-
int input_width;
17-
int input_channel;
18-
int cls_number;
19-
std::vector<std::string> input_blob_name;
20-
std::vector<std::string> output_blob_name;
6+
std::shared_ptr<BaseInferCoreFactory> infer_core_factory;
7+
std::shared_ptr<BaseDetectionPreprocessFactory> preprocess_factory;
8+
int input_height;
9+
int input_width;
10+
int input_channel;
11+
int cls_number;
12+
std::vector<std::string> input_blob_name;
13+
std::vector<std::string> output_blob_name;
2114
};
2215

2316
class Detection2DRTDetrFactory : public BaseDetection2DFactory {
2417
public:
2518
Detection2DRTDetrFactory(const RTDetrParams &params) : params_(params)
2619
{}
27-
std::shared_ptr<detection_2d::BaseDetectionModel> Create() override
20+
std::shared_ptr<BaseDetectionModel> Create() override
2821
{
2922
return CreateRTDetrDetectionModel(
3023
params_.infer_core_factory->Create(), params_.preprocess_factory->Create(),
@@ -37,31 +30,31 @@ class Detection2DRTDetrFactory : public BaseDetection2DFactory {
3730
};
3831

3932
std::shared_ptr<BaseDetection2DFactory> CreateRTDetrDetectionModelFactory(
40-
std::shared_ptr<inference_core::BaseInferCoreFactory> infer_core_factory,
41-
std::shared_ptr<detection_2d::BaseDetectionPreprocessFactory> preprocess_factory,
42-
int input_height,
43-
int input_width,
44-
int input_channel,
45-
int cls_number,
46-
const std::vector<std::string> &input_blob_name,
47-
const std::vector<std::string> &output_blob_name)
33+
std::shared_ptr<BaseInferCoreFactory> infer_core_factory,
34+
std::shared_ptr<BaseDetectionPreprocessFactory> preprocess_factory,
35+
int input_height,
36+
int input_width,
37+
int input_channel,
38+
int cls_number,
39+
const std::vector<std::string> &input_blob_name,
40+
const std::vector<std::string> &output_blob_name)
4841
{
4942
if (infer_core_factory == nullptr || preprocess_factory == nullptr)
5043
{
5144
throw std::invalid_argument("[CreateRTDetrDetectionModelFactory] Got invalid input arguments!");
5245
}
5346

5447
RTDetrParams params;
55-
params.infer_core_factory = infer_core_factory;
56-
params.preprocess_factory = preprocess_factory;
57-
params.input_height = input_height;
58-
params.input_width = input_width;
59-
params.input_channel = input_channel;
60-
params.cls_number = cls_number;
61-
params.input_blob_name = input_blob_name;
62-
params.output_blob_name = output_blob_name;
48+
params.infer_core_factory = infer_core_factory;
49+
params.preprocess_factory = preprocess_factory;
50+
params.input_height = input_height;
51+
params.input_width = input_width;
52+
params.input_channel = input_channel;
53+
params.cls_number = cls_number;
54+
params.input_blob_name = input_blob_name;
55+
params.output_blob_name = output_blob_name;
6356

6457
return std::make_shared<Detection2DRTDetrFactory>(params);
6558
}
6659

67-
} // namespace detection_2d
60+
} // namespace easy_deploy

detection_2d/detection_2d_rt_detr/test/test_detection_2d_rt_detr.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#include <gtest/gtest.h>
22

3-
#include "detection_2d_util/detection_2d_util.h"
4-
#include "detection_2d_rt_detr/rt_detr.h"
3+
#include "detection_2d_util/detection_2d_util.hpp"
4+
#include "detection_2d_rt_detr/rt_detr.hpp"
55
#include "test_utils/detection_2d_test_utils.hpp"
66

7-
using namespace inference_core;
8-
using namespace detection_2d;
9-
using namespace test_utils;
7+
using namespace easy_deploy;
108

119
#define GEN_TEST_CASES(Tag, FixtureClass) \
1210
TEST_F(FixtureClass, test_rt_detr_##Tag##_correctness) \
@@ -33,7 +31,7 @@ class BaseRTDetrFixture : public testing::Test {
3331

3432
#ifdef ENABLE_TENSORRT
3533

36-
#include "trt_core/trt_core.h"
34+
#include "trt_core/trt_core.hpp"
3735

3836
class RTDetr_TensorRT_Fixture : public BaseRTDetrFixture {
3937
public:
@@ -67,7 +65,7 @@ GEN_TEST_CASES(tensorrt, RTDetr_TensorRT_Fixture);
6765

6866
#ifdef ENABLE_ORT
6967

70-
#include "ort_core/ort_core.h"
68+
#include "ort_core/ort_core.hpp"
7169

7270
class RTDetr_OnnxRuntime_Fixture : public BaseRTDetrFixture {
7371
public:

detection_2d/detection_2d_yolov8/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ add_compile_options(-O3 -Wextra -Wdeprecated -fPIC)
66
set(CMAKE_CXX_STANDARD 17)
77

88
find_package(OpenCV REQUIRED)
9-
find_package(glog REQUIRED)
109

1110
include_directories(
1211
include
@@ -19,9 +18,9 @@ set(source_file src/yolov8.cpp
1918
add_library(${PROJECT_NAME} SHARED ${source_file})
2019

2120
target_link_libraries(${PROJECT_NAME} PUBLIC
22-
glog::glog
2321
${OpenCV_LIBS}
2422
deploy_core
23+
common_utils
2524
)
2625

2726
install(TARGETS ${PROJECT_NAME}

0 commit comments

Comments
 (0)