| 时间: 2026-04-28 | 次数: |
邓超, 赵永昆, 胡兰兰, 孙俊岭, 王伟东,等.基于改进YOLOv7的钢材表面瑕疵检测算法研究[J].河南理工大学学报(自然科学版),2026,45(3):21-29.
DENG C, ZHAO Y K, HU L L, et al.Study on steel surface defect detection algorithm based on improved YOLOv7[J].Journal of Henan Polytechnic University(Natural Science) ,2026,45(3):21-29.
基于改进YOLOv7的钢材表面瑕疵检测算法研究
邓超, 赵永昆, 胡兰兰, 孙俊岭, 王伟东
河南理工大学 物理与电子信息学院,河南 焦作 454003
摘要: 目的 为提高对钢材表面瑕疵的检测能力,提出一种基于改进YOLOv7的钢材表面瑕疵检测算法。 方法 针对YOLOv7原模型不擅长检测小目标瑕疵的问题,对原始特征融合网络中的SPPCSPC模块,结合BiFormer注意力机制,引入动态查询感知注意力,增强网络捕捉依赖长距离上下文的能力,提高网络提取特征的能力;引入针对小目标有效的损失计算方法NWD,避免由于边界框离散变化而引起IoU的敏感性,通过丰富微小目标对应的正样本数量,提高检测精确度。以上2种改进策略重点关注模型对小目标瑕疵的检测能力,同时使用时会影响模型对中目标瑕疵和大目标瑕疵的检测效果。为了更好地检测钢材表面大小不一的瑕疵目标,引入轻量级上采样算子CARAFE,增大上采样视野,同时根据不同实例动态生成自适应内核,均衡网络对不同尺寸目标检测能力,使模型总体检测效果达到最佳。 结果 在GC10-DET数据集上,提出的改进算法与原YOLOv7算法比较,mAP@0.5提高3.1%,mAP@0.5∶0.95提高5.3%,精确度提高6.6%,召回率提高5.5%,且具有较好的实时性。 结论 与主流目标检测算法和先进钢材表面瑕疵检测算法对比,提出的改进算法综合优势较好,能够高效检测钢材表面瑕疵。
关键词:钢材表面瑕疵检测;BiFormer注意力机制;NWD;CARAFE
doi:10.16186/j.cnki.1673-9787.2023100021
基金项目:国家自然科学基金资助项目(62101176);河南省科技攻关项目(232102210100,242102210082);河南理工大学基本科研业务费基础研究项目(NSFRF230601,NSFRF240621)
收稿日期:2025/05/10
修回日期:2025/08/18
出版日期:2026/04/28
Study on steel surface defect detection algorithm based on improved YOLOv7
Deng Chao, Zhao Yongkun, Hu Lanlan, Sun Junling, Wang Weidong
School of Physics and Electronic Information Engineering, Henan Polytechnic University, Jiaozuo 454003, Henan, China
Abstract: Objectives To improve the detection ability of steel surface defects in industry, a steel surface defect detection algorithm based on improved YOLOv7 was proposed. Methods Aiming at the problem that the original model of YOLOv7 was not good at detecting small target defects,the SPPCSPC module in the original feature fusion network was combined with the BiFormer attention mechanism was combined with the SPPCSPC module in the original feature fusion network, the dynamic query aware attention was introduced, the ability of the network to capture long-distance context dependencies was enhanced, the ability of the network to extract features was improved. An effective loss calculation method NWD for small targets was introduced to avoid the sensitivity of IoU caused by the discrete change of the bounding box, the detection accuracy was improved by improving the number of positive samples corresponding to small targets. The ability of the model to detect the defects of small targets was emphasized by the above two improvement strategies, when used at the same time, the detection effect of the model for medium target defects and large target defects would be affected. In order to better detect defect targets of different sizes on steel surfaces, the lightweight up-sampling operator CARAFE was introduced to increase the up-sampling field of view. At the same time, the adaptive kernel was dynamically generated according to different instances, the ability of the network to detect objects of different sizes was balanced, the overall detection effect of the model was improved to the best. Results On the GC10-DET dataset, compared with the original YOLOv7 algorithm, the improved algorithm proposed in this paper increased mAP@0.5 by 3.1%, mAP@0.5∶0.95 by 5.3%, the precision by 6.6%, and the recall rate by 5.5%, which also hasd good real-time performance. Conclusions Compared with the mainstream target detection algorithm and advanced steel surface defect detection algorithm, the improved algorithm proposed in this paper has d better comprehensive advantages, and could realize efficient steel surface defect detection.
Key words:steel surface defect detection;BiFormer attention mechanism;NWD;CARAFE