未验证 提交 40d58469 编写于 作者: G Guanghua Yu 提交者: GitHub

fix picodet output name in openvino demo (#6114)

上级 c103d025
...@@ -13,66 +13,63 @@ ...@@ -13,66 +13,63 @@
// limitations under the License. // limitations under the License.
// reference from https://github.com/RangiLyu/nanodet/tree/main/demo_openvino // reference from https://github.com/RangiLyu/nanodet/tree/main/demo_openvino
#ifndef _PICODET_OPENVINO_H_ #ifndef _PICODET_OPENVINO_H_
#define _PICODET_OPENVINO_H_ #define _PICODET_OPENVINO_H_
#include <string>
#include <opencv2/core.hpp>
#include <inference_engine.hpp> #include <inference_engine.hpp>
#include <opencv2/core.hpp>
#include <string>
#define image_size 416 #define image_size 416
typedef struct HeadInfo {
typedef struct HeadInfo std::string cls_layer;
{ std::string dis_layer;
std::string cls_layer; int stride;
std::string dis_layer;
int stride;
} HeadInfo; } HeadInfo;
typedef struct BoxInfo typedef struct BoxInfo {
{ float x1;
float x1; float y1;
float y1; float x2;
float x2; float y2;
float y2; float score;
float score; int label;
int label;
} BoxInfo; } BoxInfo;
class PicoDet class PicoDet {
{
public: public:
PicoDet(const char* param); PicoDet(const char *param);
~PicoDet(); ~PicoDet();
InferenceEngine::ExecutableNetwork network_; InferenceEngine::ExecutableNetwork network_;
InferenceEngine::InferRequest infer_request_; InferenceEngine::InferRequest infer_request_;
// static bool hasGPU; // static bool hasGPU;
std::vector<HeadInfo> heads_info_{ std::vector<HeadInfo> heads_info_{
// cls_pred|dis_pred|stride // cls_pred|dis_pred|stride
{"save_infer_model/scale_0.tmp_1", "save_infer_model/scale_4.tmp_1", 8}, {"transpose_0.tmp_0", "transpose_1.tmp_0", 8},
{"save_infer_model/scale_1.tmp_1", "save_infer_model/scale_5.tmp_1", 16}, {"transpose_2.tmp_0", "transpose_3.tmp_0", 16},
{"save_infer_model/scale_2.tmp_1", "save_infer_model/scale_6.tmp_1", 32}, {"transpose_4.tmp_0", "transpose_5.tmp_0", 32},
{"save_infer_model/scale_3.tmp_1", "save_infer_model/scale_7.tmp_1", 64}, {"transpose_6.tmp_0", "transpose_7.tmp_0", 64},
}; };
std::vector<BoxInfo> detect(cv::Mat image, float score_threshold, float nms_threshold); std::vector<BoxInfo> detect(cv::Mat image, float score_threshold,
float nms_threshold);
private: private:
void preprocess(cv::Mat& image, InferenceEngine::Blob::Ptr& blob); void preprocess(cv::Mat &image, InferenceEngine::Blob::Ptr &blob);
void decode_infer(const float*& cls_pred, const float*& dis_pred, int stride, float threshold, std::vector<std::vector<BoxInfo>>& results); void decode_infer(const float *&cls_pred, const float *&dis_pred, int stride,
BoxInfo disPred2Bbox(const float*& dfl_det, int label, float score, int x, int y, int stride); float threshold,
static void nms(std::vector<BoxInfo>& result, float nms_threshold); std::vector<std::vector<BoxInfo>> &results);
std::string input_name_; BoxInfo disPred2Bbox(const float *&dfl_det, int label, float score, int x,
int input_size_ = image_size; int y, int stride);
int num_class_ = 80; static void nms(std::vector<BoxInfo> &result, float nms_threshold);
int reg_max_ = 7; std::string input_name_;
int input_size_ = image_size;
int num_class_ = 80;
int reg_max_ = 7;
}; };
#endif #endif
...@@ -38,8 +38,8 @@ typedef struct BoxInfo { ...@@ -38,8 +38,8 @@ typedef struct BoxInfo {
} BoxInfo; } BoxInfo;
class PicoDet { class PicoDet {
public: public:
PicoDet(const char* param); PicoDet(const char *param);
~PicoDet(); ~PicoDet();
...@@ -48,26 +48,23 @@ class PicoDet { ...@@ -48,26 +48,23 @@ class PicoDet {
std::vector<HeadInfo> heads_info_{ std::vector<HeadInfo> heads_info_{
// cls_pred|dis_pred|stride // cls_pred|dis_pred|stride
{"save_infer_model/scale_0.tmp_1", "save_infer_model/scale_4.tmp_1", 8}, {"transpose_0.tmp_0", "transpose_1.tmp_0", 8},
{"save_infer_model/scale_1.tmp_1", "save_infer_model/scale_5.tmp_1", 16}, {"transpose_2.tmp_0", "transpose_3.tmp_0", 16},
{"save_infer_model/scale_2.tmp_1", "save_infer_model/scale_6.tmp_1", 32}, {"transpose_4.tmp_0", "transpose_5.tmp_0", 32},
{"save_infer_model/scale_3.tmp_1", "save_infer_model/scale_7.tmp_1", 64}, {"transpose_6.tmp_0", "transpose_7.tmp_0", 64},
}; };
std::vector<BoxInfo> detect(cv::Mat image, std::vector<BoxInfo> detect(cv::Mat image, float score_threshold,
float score_threshold,
float nms_threshold); float nms_threshold);
private: private:
void preprocess(cv::Mat& image, InferenceEngine::Blob::Ptr& blob); void preprocess(cv::Mat &image, InferenceEngine::Blob::Ptr &blob);
void decode_infer(const float*& cls_pred, void decode_infer(const float *&cls_pred, const float *&dis_pred, int stride,
const float*& dis_pred,
int stride,
float threshold, float threshold,
std::vector<std::vector<BoxInfo>>& results); std::vector<std::vector<BoxInfo>> &results);
BoxInfo disPred2Bbox( BoxInfo disPred2Bbox(const float *&dfl_det, int label, float score, int x,
const float*& dfl_det, int label, float score, int x, int y, int stride); int y, int stride);
static void nms(std::vector<BoxInfo>& result, float nms_threshold); static void nms(std::vector<BoxInfo> &result, float nms_threshold);
std::string input_name_; std::string input_name_;
int input_size_ = image_size; int input_size_ = image_size;
int num_class_ = 80; int num_class_ = 80;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册