# An Improved Feature Pyramid Network and Metric Learning Approach for Rail Surface Defect Detection
## 5 Conclusions  
Aiming at the complex rail surface, this paper proposed a rail surface defect detection method based on an improved FPN and metric learning. Based on FPN, the deformable convolution was replaced by traditional convolution to deal with the problem of the different defect sizes and easy deformation. The CBAM was added to enhance the weight of the defect features and reduce the amount of calculation. The RPN was added to extract the features and locate the bounding boxes of the small sample defects. In order to solve the problem of having only a few samples, which cannot meet the training requirements of the model, the improved FPN was pretrained on the MS COCO dataset, and the trained parameters were transferred to the rail defect detection model. Based on metric learning, a multimode network was established to classify the defects by calculating the distance between each modality and the embedded feature vector. The effectiveness of our method was verified by comparison experiments and ablation experiments. The results showed that the mAP (5-way 5-shot) of our method was 73.42% on the miniImageNet dataset and 63.29% on the rail defect dataset. Due to the complex features and high interclass similarity of the rail surface defects, the mAP values of our method on the rail defect dataset were all lower than those of the miniImageNet dataset. In terms of the limitations, our method was easily affected by the sample size and focused more on extracting the ROI, which needs to be further improved in the classifier part. In the future, we aim to develop and improve different methods to locate and classify rail surface defects. In addition to this, we will investigate data augmentation methods to enrich the current dataset and further improve the accuracy of classification.  
Conceptualization, [PERSON] and S.G.; methodology, Z.H. and S.G.; software, Z.H.; validation, Z.H. and S.G.; formal analysis, Z.H. and J.L.; investigation, Z.H.; resources, Z.H. and X.A.; data curation, Z.H.; writing--original draft preparation, Z.H.; writing--review and editing, Z.H., S.G. and Y.H.; visualization, Z.H.; supervision, [PERSON] and X.A.; project administration, Z.H.; funding acquisition, Z.H. and Y.H. All authors have read and agreed to the published version of the manuscript.  
This study was partially funded by the National Natural Science Foundation of China under Grant 62103076 and partially funded by the Key Science and Technology Program of Henan Province (No. 222102220054, 232102210356).  
Not applicable.  
The current research datasets can be downloaded at [[http://icn.bjtu.edu.cn/Visint/resources/RSDDs.aspx](http://icn.bjtu.edu.cn/Visint/resources/RSDDs.aspx)]([http://icn.bjtu.edu.cn/Visint/resources/RSDDs.aspx](http://icn.bjtu.edu.cn/Visint/resources/RSDDs.aspx)) (accessed on 5 June 2022), the miniImageNet datasets at [[https://www.kaggle.com/datasets/arjunashok33/miniimagenet](https://www.kaggle.com/datasets/arjunashok33/miniimagenet)]([https://www.kaggle.com/datasets/arjunashok33/miniimagenet](https://www.kaggle.com/datasets/arjunashok33/miniimagenet)) (accessed on 4 September 2022), and the code is provided at [[https://github.com/poetteop/rail_defect_detection](https://github.com/poetteop/rail_defect_detection)]([https://github.com/poetteop/rail_defect_detection](https://github.com/poetteop/rail_defect_detection)) (accessed on 25 April 2023).  
The authors thank the editors and anonymous reviewers for their valuable suggestions.  
The authors declare no conflict of interest.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Method** & **mAP of 5-Way 1-Shot** & **mAP of 5-Way 5-Shot** \\ \hline Matching Network & 35.83\% & 46.92\% \\ Prototypical Network & 43.33\% & 48.45\% \\ MAML & 41.36\% & 49.72\% \\ Relation Network & 45.20\% & 51.36\% \\ RepMet & 51.22\% & 59.63\% \\ Ours & 54.55\% & 63.29\% \\ \hline \hline \end{tabular}
\end{table}
Table 3: The mAP of the rail surface defect dataset using different methods.