## 5 Results and Discuss  
### Model Comparison  
The representatives of one-stage approaches, the DETR model, the YOLOv5 model, and the YOLOv8 model, and the representative of two-stage approaches, Faster R-CNN model, are trained with hyperparameters set. When the IOU threshold is set at 0.5 and the confident threshold is set at 0.5, the PR curve of different categories of rail defects based on these four models is shown in Figure 9. The \(AP\), the \(F1\) score, and inference time results of each category for all test samples are listed in Table 7.  
YOLOv8 is more accurate than the other three methods in all defect detection. Two contradicting factors are speed and accuracy. Traditionally, the YOLO series is famous for its fast detection speed, while Faster R-CNN loses some speed to improve detection accuracy. However, in Table 7, YOLOv8 performs at a high accuracy rate while ensuring the speed of detection, which has a mAP of 0.96 and an inference time of 0.066; the detection time is 58.9%, 376.8% and 123.2% faster than YOLO v5, DETR, and Faster R-CNN. Compared with DETR, YOLOv5 and Faster R-CNN, YOLOv8 also has the highest mAP value, 0.96; however, YOLOv5 and Faster R-CNN only have 0.896 IPS and 0.125 IPS. DETR have better performance, but DETR have slower inference time, needing 0.267 IPS for per inference. When testing, we used ground truth as a reference, and at the same time provided labels below the image for each bbox. From the detection results, these four object detection algorithms realized the automatic classification and localization of the rail internal defects \begin{table}
\begin{tabular}{c c c c c c c c c c} \hline \hline \multirow{2}{*}{**Model**} & \multirow{2}{*}{\begin{tabular}{c} **mAP** \\ **(\%)** \\ \end{tabular} } & \multicolumn{6}{c}{**AP (\%)**} & \multicolumn{6}{c}{**Threshold = 0.5**} \\ \cline{3-10}  & & \begin{tabular}{c} **Crescent-Shaped** \\ **Fatigue Cracks** \\ \end{tabular} & \begin{tabular}{c} **Fishbolt** \\ **Hole Cracks** \\ \end{tabular} & \begin{tabular}{c} **Rail Web** \\ **Cracks** \\ \end{tabular} & \begin{tabular}{c} **Rail Base** \\ **Transverse Cracks** \\ \end{tabular} & \begin{tabular}{c} **Precision** \\ **Faces** \\ \end{tabular} & \
\begin{tabular}{c} **Recall** \\ **Score** \\ \end{tabular} &
\begin{tabular}{c} **F1** \\ **Time (s)** \\ \end{tabular} \\ \hline YOLO v8 & 0.96 & 0.869 & 0.993 & 0.984 & 0.995 & 0.933 & 0.916 & 0.924 & 0.056 \\ \hline YOLOv5 & 0.757 & 0.659 & 0.789 & 0.783 & 0.799 & 0.702 & 0.771 & 0.735 & 0.089 \\ \hline DETR & 0.896 & 0.625 & 0.968 & 0.995 & 0.995 & 0.845 & 0.908 & 0.875 & 0.267 \\ \hline Faster R-CNN & 0.585 & 0.227 & 0.429 & 0.905 & 0.778 & 0.510 & 0.680 & 0.580 & 0.125 \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Performances on testing dataset algorithms. Figure 9: Performance comparison of different models. in B-scan images to further compare the performance of the detection results of these three networks. From typical detection results, YOLOv8 could precisely find the defects and outperform YOLOv5, DETR and Faster R-CNN in identification and classification, which benefits from feature fusion and a PAN structure. In contrast, DETR, YOLOv5, and Faster R-CNN have some problems. Among them, Faster R-CNN performs poorly, with a problem of detection errors and missed detection, especially in detecting fishbolt hole cracks and rail web cracks. When the defect appeared in the rail web area, Faster R-CNN could not identify the true defect or even identify the normal structures as defects. Compared to that, DETR does better in web defects detection, but missed detection still happens in bolt hole detection, YOLOv5 has better performance, but still has some problems in crescent-shaped fatigue crack detection. YOLOv8 can more accurately identify defects in the rail web and fishbolt hole crack area. However, there is no huge problem in YOLOv8. Instead, it finds the most appropriate prediction bbox.