Turkish Journal of Electrical Engineering and Computer Sciences
Author ORCID Identifier
MEHMET KOÇ: 0000-0003-2919-6011
RIDVAN ÖZDEMİR: 0000-0002-8599-1709
ÖMER GEREK: 0000-0001-8183-1356
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.
DOI
10.55730/1300-0632.4276
Keywords
Rail defect classification, deep learning, Focal Loss, adaptive weighting, railway safety, object detection
First Page
791
Last Page
808
Publisher
The Scientific and Technological Research Council of Türkiye (TÜBİTAK)
Creative Commons License

This work is licensed under a Creative Commons Attribution 4.0 International License.
Recommended Citation
KOÇ, M, ÖZDEMİR, R, & GEREK, Ö (2026). Dynamic Focal Loss adjustment for railway defect detection. Turkish Journal of Electrical Engineering and Computer Sciences 34 (5): 791-808. https://doi.org/10.55730/1300-0632.4276
Included in
Computer Engineering Commons, Computer Sciences Commons, Electrical and Computer Engineering Commons