Improved YOLOv5s rail tiny defect detection method integrating CA attention mechanism and transposed convolution
Abstract
To address challenges in railway defect detection including difficult feature extraction, low small-target detection accuracy, and complex background interference, this paper proposes an enhanced YOLOv5s-based model named CA-TC-YOLOv5s. First, a coordinate attention (CA) mechanism is integrated into the backbone's C3 module, forming a C3CA structure to improve extraction of weak rail features. Second, VariFocal Loss is adopted to replace the binary cross-entropy loss, alleviating foreground-background imbalance and enhancing detection of rare defects. Third, transposed convolution is introduced in the neck network instead of nearest-neighbor upsampling, which better restores small defect features. Experiments show that the proposed method improves rail localization accuracy by 1.8%, defect detection accuracy by 4.1%, and overall mAP by 2.9%, while accelerating model training and inference. These improvements strengthen the model's practicality and robustness in complex railway environments, supporting intelligent rail image analysis.