A lightweight YOLOv8n-based method for rail surface defect detection in complex railway environments
摘要
Rail surface defect detection faces significant challenges, including class imbalance, small-scale defect detection, and interference from complex backgrounds. To address these issues, this study proposes a lightweight rail surface defect detection method based on YOLOv8n. First, a K-means + + -based defect scale prior optimization strategy is introduced to better characterize the scale distribution of rail surface defects and improve the representation of small targets. Second, a local–global collaborative attention module, named CloAtt, is embedded into the C2f. structure to enhance fine-grained defect feature representation while suppressing complex background noise. Third, an Attention-Guided Bidirectional Feature Pyramid Network, named ABiFPN, is designed to improve multi-scale feature fusion and reduce redundant feature propagation. Furthermore, a Focal-Efficient Intersection over Union loss, named Focal-EIoU, is adopted to improve bounding box regression and enhance the learning of difficult samples. Experimental results on the ProRail dataset show that the proposed YOLOv8n-ours achieves an mAP@0.5 of 85.7%, with only 2.13M parameters and 7.5 GFLOPs. Compared with the baseline YOLOv8n, the proposed method improves detection accuracy while reducing model complexity. These results demonstrate that the proposed model provides an effective lightweight solution for rail surface defect detection. Edge-device deployment and real-time inference validation will be investigated in future work.