爱笑的小姐姐 · 5 小时前

YOLO系列模型CPU推理封装DLL测试

YOLO系列推理库封装

都属于轻量化的模型网络,可以支持部署在CPU达到实时运行,从而降低企业模板模型需要GPU的成本开销,基于这个场景,本人基于OpenCV与OpenVINO封装了YOLO系列(YOLOv5、YOLOv8、YOLOv10、YOLO11)模型的对象检测、实例分割、OBB对象检测、姿态评估 C++ 推理功能、导出DLL以后支持C++与C#调用。封装的与支持的常用主流YOLO模型如下:

image.png

客户端调用

基于封装好的DLL,导出的接口定义如下:

class YOLOQTingInferAlgo {
public: 
virtual void initConfig(std::string onnxpath, float score, int input_w, int input_h, bool gpu) = 0;  
virtual void detect(cv::Mat & frame, std::vector<YOLODetBox> &results) = 0;
};

支持基于YOLO系列自定义训练的模型推理部署,然后第三方应用集成与调用,只需要三行代码即可完成。

YOLOv5推理代码片段

std::shared_ptr<YOLOv5SegOpenVINO> detector(new YOLOv5SegOpenVINO());
detector->initConfig("D:/python/yolov5-7.0/yolov5s-seg.onnx", 0.25, 640, 640, false);
detector->detect(frame, results);

推理结果

image.png

YOLOv8推理代码片段

std::shared_ptr<YOLOv8OpenVINODetector> detector(new YOLOv8OpenVINODetector());
detector>initConfig("D:/projects/yolov8n.onnx", 0.25, 640, 640, false);
detector->detect(frame, results);

image.png

YOLOv10推理代码片段

std::shared_ptr<YOLOv10OpenVINODetector> detector(new YOLOv10OpenVINODetector());
detector->initConfig("D:/projects/yolov10n.onnx", 0.25, 640, 640, false);
detector->detect(frame, results);

image.png

YOLOv11 推理代码片段

std::shared_ptr<YOLO11OpenVINODetector> detector(new YOLO11OpenVINODetector());
detector->initConfig("D:/python/my_yolov8_train_demo/yolo11n.onnx", 0.25, 640, 640, false);
detector->detect(frame, results);

运行结果如下:

image.png

image.png

END

作者:gloomyfish
来源:OpenCV学堂

推荐阅读

欢迎大家点赞留言,更多Arm技术文章动态请关注极术社区嵌入式AI专栏欢迎添加极术小姐姐微信(id:aijishu20)加入技术交流群,请备注研究方向。

推荐阅读
关注数
18781
内容数
1334
嵌入式端AI,包括AI算法在推理框架Tengine,MNN,NCNN,PaddlePaddle及相关芯片上的实现。欢迎加入微信交流群,微信号:aijishu20(备注:嵌入式)
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息