Add C++ Classify inference example (#6868)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
1b37a13131
commit
b62b20d517
4 changed files with 380 additions and 223 deletions
|
|
@ -19,53 +19,59 @@
|
|||
#endif
|
||||
|
||||
|
||||
enum MODEL_TYPE {
|
||||
enum MODEL_TYPE
|
||||
{
|
||||
//FLOAT32 MODEL
|
||||
YOLO_ORIGIN_V5 = 0,
|
||||
YOLO_ORIGIN_V8 = 1,//only support v8 detector currently
|
||||
YOLO_POSE_V8 = 2,
|
||||
YOLO_CLS_V8 = 3,
|
||||
YOLO_ORIGIN_V8_HALF = 4,
|
||||
YOLO_DETECT_V8 = 1,
|
||||
YOLO_POSE = 2,
|
||||
YOLO_CLS = 3,
|
||||
|
||||
//FLOAT16 MODEL
|
||||
YOLO_DETECT_V8_HALF = 4,
|
||||
YOLO_POSE_V8_HALF = 5,
|
||||
YOLO_CLS_V8_HALF = 6
|
||||
};
|
||||
|
||||
|
||||
typedef struct _DCSP_INIT_PARAM {
|
||||
std::string ModelPath;
|
||||
MODEL_TYPE ModelType = YOLO_ORIGIN_V8;
|
||||
std::vector<int> imgSize = {640, 640};
|
||||
float RectConfidenceThreshold = 0.6;
|
||||
typedef struct _DL_INIT_PARAM
|
||||
{
|
||||
std::string modelPath;
|
||||
MODEL_TYPE modelType = YOLO_DETECT_V8;
|
||||
std::vector<int> imgSize = { 640, 640 };
|
||||
float rectConfidenceThreshold = 0.6;
|
||||
float iouThreshold = 0.5;
|
||||
bool CudaEnable = false;
|
||||
int LogSeverityLevel = 3;
|
||||
int IntraOpNumThreads = 1;
|
||||
} DCSP_INIT_PARAM;
|
||||
int keyPointsNum = 2;//Note:kpt number for pose
|
||||
bool cudaEnable = false;
|
||||
int logSeverityLevel = 3;
|
||||
int intraOpNumThreads = 1;
|
||||
} DL_INIT_PARAM;
|
||||
|
||||
|
||||
typedef struct _DCSP_RESULT {
|
||||
typedef struct _DL_RESULT
|
||||
{
|
||||
int classId;
|
||||
float confidence;
|
||||
cv::Rect box;
|
||||
} DCSP_RESULT;
|
||||
std::vector<cv::Point2f> keyPoints;
|
||||
} DL_RESULT;
|
||||
|
||||
|
||||
class DCSP_CORE {
|
||||
class YOLO_V8
|
||||
{
|
||||
public:
|
||||
DCSP_CORE();
|
||||
YOLO_V8();
|
||||
|
||||
~DCSP_CORE();
|
||||
~YOLO_V8();
|
||||
|
||||
public:
|
||||
char *CreateSession(DCSP_INIT_PARAM &iParams);
|
||||
char* CreateSession(DL_INIT_PARAM& iParams);
|
||||
|
||||
char *RunSession(cv::Mat &iImg, std::vector<DCSP_RESULT> &oResult);
|
||||
char* RunSession(cv::Mat& iImg, std::vector<DL_RESULT>& oResult);
|
||||
|
||||
char *WarmUpSession();
|
||||
char* WarmUpSession();
|
||||
|
||||
template<typename N>
|
||||
char *TensorProcess(clock_t &starttime_1, cv::Mat &iImg, N &blob, std::vector<int64_t> &inputNodeDims,
|
||||
std::vector<DCSP_RESULT> &oResult);
|
||||
char* TensorProcess(clock_t& starttime_1, cv::Mat& iImg, N& blob, std::vector<int64_t>& inputNodeDims,
|
||||
std::vector<DL_RESULT>& oResult);
|
||||
|
||||
char* PreProcess(cv::Mat& iImg, std::vector<int> iImgSize, cv::Mat& oImg);
|
||||
|
||||
|
|
@ -73,11 +79,11 @@ public:
|
|||
|
||||
private:
|
||||
Ort::Env env;
|
||||
Ort::Session *session;
|
||||
Ort::Session* session;
|
||||
bool cudaEnable;
|
||||
Ort::RunOptions options;
|
||||
std::vector<const char *> inputNodeNames;
|
||||
std::vector<const char *> outputNodeNames;
|
||||
std::vector<const char*> inputNodeNames;
|
||||
std::vector<const char*> outputNodeNames;
|
||||
|
||||
MODEL_TYPE modelType;
|
||||
std::vector<int> imgSize;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue