PGCI-YOLO: a railway fastener detection algorithm based on improved YOLOv8n
摘要
Railway fasteners are critical components for maintaining track structural stability and ensuring the safe operation of trains. Defect detection of fasteners plays a vital role in achieving intelligent railway maintenance. To address the challenge of balancing accuracy and efficiency in existing detection models, this paper proposes a lightweight detection algorithm based on the YOLOv8n architecture—PGCI-YOLO. First, a Pyramid Spatial Attention Module (PSAM) is designed, which integrates multi-scale channel grouping and spatial attention to significantly enhance the model’s perception of complex target regions. Second, the GSCSP module is integrated into the Neck. Composed of GSConv and VoV-GSCSP, this module reduces the number of parameters and computational complexity while preserving rich semantic information, thereby improving inference efficiency. Third, the CARAFE upsampling operator replaces traditional interpolation methods to enable adaptive, content-aware feature reconstruction. Finally, a novel regression loss function, Inner-Focaler-MPDIoU (IFM), is constructed by combining sample difficulty weighting, corner modeling, and internal consistency constraints, which improves bounding box localization accuracy and accelerates model convergence. Experimental results show that PGCI-YOLO achieves 97.3% mAP@0.5, 69.3% mAP@0.5:0.95, and an inference speed of 116 FPS on the M-type fastener dataset, with only 2.67 M parameters and 6.7 GFLOPs, comprehensively outperforming other mainstream models. Compared with the original YOLOv8n, PGCI-YOLO improves mAP@0.5 by 2.1%, increases inference speed by 8 FPS, reduces parameters by 11%, decreases computation by 17.3%, and shrinks model size by 12.7%. Further tests on the E-type fastener dataset and edge platforms such as Jetson AGX Orin and KC-7600 demonstrate the model’s strong robustness, generalization capability, and deployment adaptability. PGCI-YOLO achieves an excellent balance between detection accuracy and real-time performance while maintaining a lightweight architecture, making it highly suitable for practical engineering applications.