原文链接

药片数据集

训练集:由 92 幅图像组成,每幅图像都标注了类别 pill.

验证集:包括 23 幅图像和相应的注释。

数据集下载地址:

https://github.com/ultralytics/assets/releases/download/v0.0.0/medical-pills.zip、

数据标签文件配置:

Image

YOLO11模型训练

训练命令行

yolo detect train data=medical-pills.yaml model=yolo11n.pt epochs=100 imgsz=640

Image

PR曲线

Image

Image

部署与量化推理演示

转换为ONNX格式文件:

yolo export model=best.pt format=onnx

Image

NNCF介绍

神经网络压缩框架 (NNCF) 提供了一套训练后和训练时算法,用于优化 OpenVINO™ 中神经网络的推理,同时将准确率下降降至最低。官方代码库地址:

    https://github.com/openvinotoolkit/nncf

    NNCF PTQ 是最简洁的INT8量化方法,只需要模型和一个小的 (~300 个样本) 校准数据集即可实现对模型的INT8量化。对训练后的模型转为IR格式以后用,OpenVINO的NNCF框架把模型量化为INT8模式。PTQ的量化代码如下:

    Image

    运行结果如下:

    Image

    基于OpenVINO2025 C++ SDK部署INT8量化后模型,推理效果如下:

    Image

    OpenVINO + YOLO11药片检测的推理代码如下:

    std::string xmlpath = "D:/images/bird_test/pills_best_int8.xml";std::string labelpath = "D:/images/bird_test/labels.txt";std::shared_ptr<YOLO11Detector> detector(new YOLO11Detector());detector->initConfig(xmlpath, labelpath, 0.2, 640, 640);cv::Mat image = cv::imread("D:/pills.jpg");detector->detect(image);cv::imshow("YOLO11药片检测+OpenVINO2025", image);cv::waitKey(0);cv::destroyAllWindows();

    玩转YOLOv8通杀YOLO系列所有模型!

    Logo

    为开发者提供丰富的英特尔开发套件资源、创新技术、解决方案与行业活动。欢迎关注!

    更多推荐