Journal of Computer Applications

    Next Articles

YOLOv8n-based algorithm for cigarette defect detection and deployment

  

  • Received:2025-01-13 Revised:2025-03-14 Online:2025-04-27 Published:2025-04-27

基于YOLOv8n的烟支缺陷检测算法及部署

张澎涛1,张宪奇1,黄建平1,管雪梅2,于帅1,刘振1   

  1. 1. 东北林业大学
    2. 黑龙江省哈尔滨市香坊区东北林业大学
  • 通讯作者: 张宪奇
  • 基金资助:
    国家自然科学基金

Abstract: To address challenges of low precision and recall in small-target defect detection for cigarette inspection, this study proposes CSDD-YOLO(Cigarette Stick Defect Detection YOLO), an enhanced YOLOv8n (You Only Look Once version 8n)-based algorithm. Framework integrates a dedicated P2 detection head with a MscalSeq (Multi-scale Sequence ) module to strengthen multi-scale feature fusion for tiny defects. A lightweight C3k2 backbone replaces C2f modules to balance efficiency and deep feature extraction, while a CKAttention (Choose Kernel Attention ) mechanism enhances discriminative capabilities. Further optimized via LAMP (Layer Adaptive Magnitude-based Pruning), model reduces parameters significantly without compromising performance. Experiments on real-world datasets demonstrate a mean Average Precision(mAP) of 94.7% (7.5% higher than baseline) with only 36% of original model size. Deployed via C++/ONNX Runtime(Open Neural Network Exchange Runtime), solution achieves real-time detection accuracy, proving highly applicable for industrial quality control systems.

Key words: cigarette appearance defect detection, YOLOv8n, small target detection, Layer Adaptive Magnitude-based Pruning &#40, LAMP&#41

摘要: 针对烟支缺陷检测在小目标检测上精度及召回率不佳的问题,提出了一种基于YOLOv8n架构增强算法CSDD-YOLO(Cigarette Stick Defect Detection YOLO)。首先,增加一个专门的微小物体检测头P2,然后使用尺度序列特征融合(MscalSeq)模块增强网络的多尺度信息提取能力,将P2检测头与尺度序列特征融合模块(MscalSeq)相结合进一步增强微小物体检测能力。同时设计选择核注意力机制(CKAttention),以提高检测和分割能力。将网络中的骨干层的C2f模块替换为C3k2模块,在轻量化的同时又能提取深层次特征。最后,使用LAMP(Layer Adaptive Magnitude-based Pruning)对改进模型优化,减少模型大小和参数量。利用真实采集的烟支缺陷数据集进行了实验,结果表明平均精度均值(mAP)达到了94.7%,相比原算法提高了7.5个百分点,但模型大小仅为原模型的36%。基于ONNX Runtime(Open Neural Network Exchange Runtime)框架下进行C++推理,与YOLOv8n算法相比,改进算法能在满足实时检测要求的条件下获得更高的平均精确度,适用于工业领域下实时目标检测。

关键词: 香烟外观缺陷检测, YOLOv8n, 小目标检测, LAMP, 模型部署

CLC Number: