In the field of industrial material production and management, traditional detection methods are difficult to meet the diverse detection requirements for surface coating cracks and other defects of aluminum profiles. Moreover, existing detection models have problems of missed detection and false detection of small targets. This paper proposes a surface defect detection method for aluminum profiles based on YOLOv8n-SE. By embedding the SE attention mechanism in the neck network of the YOLOv8n model, the feature extraction ability is enhanced, improving the positioning accuracy and defect sensitivity of the defect area. Experiments were conducted using an aluminum profile defect dataset, and the proposed method was compared with lightweight models such as Faster R-CNN and YOLOv5n combined with different attention mechanisms. The research results show that the average precision (mAP) of the improved model reaches 75.0%, a 4.2% higher than the original YOLOv8n model, with the number of parameters remaining basically unchanged and the inference speed only decreasing by 0.3%. The improved YOLOv8n model with the embedded SE attention mechanism can effectively improve the recognition effect of surface defects of aluminum profiles, solve the problem of missed detection and false detection of small targets, and maintain the efficient inference advantage of lightweight models, making it suitable for the defect detection requirements of aluminum profiles in industrial scenarios.
SE注意力机制算法流程见图3。该方法通过压缩空间维度以提取全局信息,再经变换校准通道权重,对特征图各通道的权重进行调整,从而使模型更加聚焦于关键特征,减少无效信息的干扰。其压缩(Squeeze)步骤如下:输入特征图 U (维度为C×W×H),经过全局平均池化操作Fsq,将空间维度W×H压缩为1×1,生成通道描述符(维度为1×1×C),用以聚合各通道的全局信息。计算式为
,
式中: Zc 为第c个通道经全局平均池化后的通道描述符;为全局平均池化操作函数; Uc 为输入特征图 U 的第c个通道(维度为W×H);W、H分别为输入特征图的宽度和高度;i、j分别为特征图空间维度的列、行索引。
激励(Excitation)步骤为:压缩后通道特征经激励函数Fex处理,输出与原通道数一致的权重向量 S (维度为1×1×C),实现通道权重的校准,计算式为
,
式中:为激励操作函数; Z 为压缩步骤生成的通道描述符向量(维度为1×1×C); W 为全连接层参数矩阵,其中 W1、 W2分别为升维、降维全连接层参数矩阵;为ReLU激活函数;为Sigmoid激活函数。
缩放(Scale)步骤为:将校准后的权重向量 S 经缩放操作Fsc与原特征图 U 逐通道相乘,完成对特征的注意力加权,输出增强后的特征。计算式为
,
式中:为增强后特征图的第c个通道(维度为W×H);为逐通道缩放操作函数; Uc 为原特征图的第c个通道; Sc 为校准后权重向量 S 中对应第c个通道的权重值;“”表示逐元素相乘运算。
ZENGYongjie, FANBishuang, YANGYawen,et al.YOLOv8 algorithm is improved in the defect detection of wind turbine blades applications[J].Journal of Electronic Measurement and Instrumentation, 2024, 38(8): 26-35.
[3]
TERVENJ, CÓRDOVA-ESPARZAD M, ROMERO-GONZÁLEZJ A. A comprehensive review of YOLO architectures in computer vision: from YOLOv1 to YOLOv8 and YOLO-NAS[J]. Machine Learning and Knowledge Extraction, 2023, 5(4): 1680-1716.
[4]
JIANGP Y, ERGUD, LIUF Y, et al. A review of yolo algorithm developments[J]. Procedia Computer Science, 2022,199:1066-1073.
PENGJishen, MALongze, SUNMengyu, et al. A multi-scale feature fusion enhanced detection model MFFE-YOLO[J]. Journal of Liaoning Technical University (Natural Science Edition), 2024, 43(5): 625-632.
SUNTieqiang, LIUJun, SONGChao, et al. A small target defect detection method for aluminum profile surface based on improved YOLOv8n[J]. Modern Manufacturing Engineering, 2024(12): 120-129.
[12]
YINZ J, LIH C, QIB, et al. BBW YOLO: intelligent detection algorithms for aluminium profile material surface defects[J]. Coatings, 2025, 15(6): 684.
JINGHuicheng, BAOChengming. Research on defect detection technology of aluminum profile workpiece based on improved YOLOv12[J]. Electronic Measurement Technology, 2026,49(1):216-225.
MINRui, FANGKai, CHENJuan, et al. Steel surface defect detection method based on improved YOLOv8n[J]. Internet of Things Technologies, 2025, 15(17): 30-36.
[17]
GUNUKULAA R, DES GUPTAH, SHENGV S. Detecting AI-generated images using a hybrid ResNet-SE attention model[J]. Applied Sciences, 2025, 15(13): 7421.
[18]
WANGX Y, MAS H, WUS T, et al. Detection of surface defects in steel based on dual-backbone network: MBDNet-attention-YOLO[J]. Sensors, 2025, 25(15): 4817.
[19]
XIONGJ H, LIP G, SUNY, et al. An aircraft skin defect detection method with UAV based on GB-CPP and INN-YOLO[J]. Drones, 2025, 9(9): 594.
[20]
XUY M, ZHANGK, WANGL. Metal surface defect detection using modified YOLO[J]. Algorithms, 2021, 14(9): 257.
[21]
CHENQ P, XIONGQ Q, HUANGH S, et al. An efficient and lightweight surface defect detection method for micro-motor commutators in complex industrial scenarios based on the CLS-YOLO network[J]. Electronics, 2025, 14(3): 505.
[22]
MAH T, ZHANGZ S, ZHAOJ N. A novel ST-YOLO network for steel-surface-defect detection[J]. Sensors, 2023, 23(22): 9152.
[23]
YANGD L, MAC S, YUG T, et al. Automatic defect detection of pipelines based on improved OFG-YOLO algorithm[J]. Measurement, 2025, 242: 115847.
[24]
CHENR X, CAID Y, HUX L, et al. Defect detection method of aluminum profile surface using deep self-attention mechanism under hybrid noise conditions[J]. IEEE Transactions on Instrumentation and Measurement, 2021, 70: 3524509.
[25]
BIN F, HOUF, CHEND, et al. BCM-YOLO: an improved YOLOv8-based lightweight porcelain insulator defect detection model[J]. High Voltage, 2025, 10(4): 876-889.
[26]
XIEY F, HUW T, XIES W, et al. Surface defect detection algorithm based on feature-enhanced YOLO[J]. Cognitive Computation, 2023, 15(2): 565-579.
[27]
FENGY F, HUANGJ G, DUS Y, et al. Hyper-YOLO: when visual object detection meets hypergraph computation[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2025, 47(4): 2388-2401.
[28]
HUANGJ H, ZHANGX L, JIAL J, et al. An improved you only look once model for the multi-scale steel surface defect detection with multi-level alignment and cross-layer redistribution features[J]. Engineering Applications of Artificial Intelligence, 2025, 145: 110214.
[29]
ZHOUS Y, ZENGY L, LIS C, et al. Surface defect detection of rolled steel based on lightweight model[J]. Applied Sciences, 2022, 12(17): 8905.
[30]
YUL Z, ZHUJ H, ZHAOQ, et al. An efficient YOLO algorithm with an attention mechanism for vision-based defect inspection deployed on FPGA[J]. Micromachines, 2022, 13(7): 1058.
[31]
ZHOUY. A YOLO-NL object detector for real-time detection[J]. Expert Systems with Applications, 2024, 238: 122256.
[32]
LIJ Y, SUZ F, GENGJ H, et al. Real-time detection of steel strip surface defects based on improved YOLO detection network[J]. IFAC-PapersOnLine, 2018, 51(21): 76-81.
MAJunjie, ZHANGJihong, WANGQiang, et al. Strip surface defect detection algorithm based on improved YOLOv11[J]. Journal of Iron and Steel Research, 2025, 37(10): 1345-1358.
[35]
LUL H, CHENZ C, WANGR F, et al. Yolo-inspection: defect detection method for power transmission lines based on enhanced YOLOv5s[J].Journal of Real-Time Image Processing,2023,20(5): 104.