Skip to content
Open access

Dynamic Focal Loss adjustment for railway defect detection

Sep 2026 · Turkish Journal of Electrical Engineering and Computer Sciences · 0 citations · 21 references

Abstract

Railway infrastructure is critical to the safe and efficient operation of transportation systems, and the early detection of defects is essential for preventing catastrophic failures. Automated defect detection methods are therefore crucial for maintaining continuous safety while reducing maintenance costs. Although Focal Loss is widely used in object detection under class-imbalanced conditions, its fixed α parameter may limit its effectiveness in detecting rare defects. In this study, we propose an adaptive α-tuned Focal Loss approach that dynamically adjusts class weights based on average precision (AP) values. By iteratively optimizing α without relying on gradient-based optimization, the proposed method improves the recall of underrepresented defect classes. The theoretical foundations of the proposed optimization are also investigated, including its formulation as a bilevel optimization problem. The proposed method is applied to automated railway defect detection using real-world infrastructure data. To enhance robustness and generalizability, the experimental framework incorporates online data augmentation and 5-fold cross-validation, achieving a stable mean average precision (mAP) of 93.42% ± 0.45%. Comparative visual analyses further demonstrate the model's ability to localize critical defects that are overlooked by baseline methods. Furthermore, a nonlinear relationship between α and AP is modeled through fitted curve analysis, highlighting the importance of dynamic class weighting in improving detection performance.

Read PDF

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.