Improved YOLOv7-based surface defect detection method incorporating feature retention and densely-scale spatial attention mechanisms

In recent years, convolutional neural networks (CNNs) have been widely applied to automated defect detection. However, the feature information of small defects is easily lost during feature extraction, and as the network deepens, the increased computational burden and the insufficient utilization of existing features also affect detection performance. In addition, when the model is trained using stochastic gradient descent (SGD), it may converge to a local optimum, which limits its detection performance. To address these issues, this paper proposes a method based on YOLOv7-tiny that integrates feature retaining blocks (FRBs) and densely-scale spatial attention (DSSA) blocks into the backbone network and incorporates a cosine annealing (CA) learning rate schedule during training. The proposed method, termed Cosine Annealing Learning Rate Scheduled YOLOv7 with Densely-Scale Spatial Attention and Feature Retaining Block (CA-YOLOv7-DF), is applied to surface defect detection. Experiments were conducted on the public NEU-DET dataset, and the components were analyzed through gradient-weighted class activation mapping (Grad-CAM), confusion matrices, and training convergence analysis. Under a unified training protocol with three random seeds, CA-YOLOv7-DF achieved a mean average precision (mAP) of 71.9 ± 1.2%, compared with 70.9 ± 1.0% for YOLOv7-tiny; the FRBs provided the largest average gain, whereas the effects of the DSSA blocks and the CA schedule were within the run-to-run variation. Moreover, the proposed method achieves a detection speed of 11.6 frames per second (FPS) on the Jetson Nano embedded device, which makes it applicable to low- to moderate-speed or sampling inspection. On the GC10-DET dataset, the method did not improve on YOLOv7-tiny, indicating that its benefit depends on defect scale and the amount of training data.

Authors

Institutions

Publication Details

Journal
Scientific Reports
Published
2026-11-05
DOI
https://doi.org/10.1038/s41598-026-78389-2
Primary Topic
Industrial Vision Systems and Defect Detection
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
article

Improved YOLOv7-based surface defect detection method incorporating feature retention and densely-scale spatial attention mechanisms

Hsu-Ming Chang, Young-Long Chen, Chien-Yun Ko, Yu-Chieh Chang
Scientific Reports
Industrial Vision Systems and Defect Detection
article

Improved YOLOv7-based surface defect detection method incorporating feature retention and densely-scale spatial attention mechanisms

Hsu-Ming Chang, Young-Long Chen, Chien-Yun Ko, Yu-Chieh Chang
article en

Abstract

In recent years, convolutional neural networks (CNNs) have been widely applied to automated defect detection. However, the feature information of small defects is easily lost during feature extraction, and as the network deepens, the increased computational burden and the insufficient utilization of existing features also affect detection performance. In addition, when the model is trained using stochastic gradient descent (SGD), it may converge to a local optimum, which limits its detection performance. To address these issues, this paper proposes a method based on YOLOv7-tiny that integrates feature retaining blocks (FRBs) and densely-scale spatial attention (DSSA) blocks into the backbone network and incorporates a cosine annealing (CA) learning rate schedule during training. The proposed method, termed Cosine Annealing Learning Rate Scheduled YOLOv7 with Densely-Scale Spatial Attention and Feature Retaining Block (CA-YOLOv7-DF), is applied to surface defect detection. Experiments were conducted on the public NEU-DET dataset, and the components were analyzed through gradient-weighted class activation mapping (Grad-CAM), confusion matrices, and training convergence analysis. Under a unified training protocol with three random seeds, CA-YOLOv7-DF achieved a mean average precision (mAP) of 71.9 ± 1.2%, compared with 70.9 ± 1.0% for YOLOv7-tiny; the FRBs provided the largest average gain, whereas the effects of the DSSA blocks and the CA schedule were within the run-to-run variation. Moreover, the proposed method achieves a detection speed of 11.6 frames per second (FPS) on the Jetson Nano embedded device, which makes it applicable to low- to moderate-speed or sampling inspection. On the GC10-DET dataset, the method did not improve on YOLOv7-tiny, indicating that its benefit depends on defect scale and the amount of training data.

Scientific Reports
National Taichung University of Science and Technology (TW)
Openalex Percentile: Top 18%
Industrial Vision Systems and Defect Detection
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon