# Intelligent Whistling System of Rail Train Based on YOLOv4 and U-Net
## 3 Road Condition Sensing Module
### Target Detection Model Based on YOLOv4  
(1) Model Structure  
YOLOv4 is a model proposed by [PERSON] et al. on CVPR in 2020. Some optimization strategies were added based on YOLOv3, mainly including the following: (1) upgrade Darknet53 to CSPMarknet53 to improve the backbone feature extraction network; (2) SPP and PANet structures are used to improve the strong feature extraction  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Label Category** & **Num** & **Label Category** & **Num** \\ \hline \multirow{3}{*}{Straight track} & \multirow{3}{*}{7379} & Crossing & \multirow{3}{*}{614} \\  & & Crossing & \\ \cline{1-1} \cline{5-5} \cl  
network; (3) a mosaic data-enhancement method is used; (4) take CIOU as regression Loss; (5) Mish activation function is used. Figure 5 shows the network structure of YOLOv4. (2) Model Training  
The deep learning framework used in this paper is PyTorch, developed by the Facebook artificial intelligence research institute [23], and the model is trained on a computer with Intel Core i7-11800H CPU and NVIDIA GeForce RTX3060 GPU. In order to ensure the reliability of the experiment, the subsequent tests of the model are carried out on the same platform. Table 3 shows the training parameters of YOLOv4. Figure 5: Network structure of YOLOv4. \begin{table}
\begin{tabular}{c c} \hline \hline
**Training Parameters** & **Value** \\ \hline Dataset size & 9000 \(\times\) 608 \(\times\) 608 \(\times\) 3 \\ Proportion of Training, verification, test set & 8:1:1 \\ Network input size & 608 \(\times\) 608 \(\times\) 3 \\ Number of categories & 11 \\ Numerical accuracy & Float32 \\ Training total Epochs & 200 \\ Number of Epochs in freezing phase & 50 \\ Number of Epochs in unfreezing phase & 150 \\ Batch\_size in freeze phase & 8 \\ Batch\_size in unfreezing phase & 4 \\ Step optimizer & SGD \\ Initial learning rate & 1e-2 \\ Momentum & 0.937 \\ Weight attenuation coefficient & 5e-4 \\ Weight attenuation method & Cos \\ Data enhancement method & Mosaic \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Training parameters of YOLOv4. In order to ensure the efficiency and accuracy of training, the weight of YOLOv4 based on the VOC2007 dataset was used as the model pretraining weight [24; 25]. The training process was divided into freezing and unfreezing stages. In the freezing phase, the weight of the model backbone is frozen so that the feature extraction network does not change; in the unfreezing phase, the weight is not locked [26]. In addition, the focal Loss method was used for optimization. By increasing the weight of difficult-to-distinguish samples in the Loss function, the Loss function tends to be difficult to distinguish, which helps to improve the accuracy of small sample categories and alleviates the problem of the uneven number of sample categories. The training results are shown in Figure 6. To speed up the training, the mean Average Precision (mAP) of the validation set is updated every ten Epochs [27]. It can be seen from Figure 6 that the model training process is relatively stable and has almost converged after 80 Epochs of training. At the end of the training, the Loss of the model on the training set and verification set is 2.76 \(\times\) 10\({}^{-2}\) and 5.21 \(\times\) 10\({}^{-2}\), the mAP values on the verification set and test set are 86.45% and 86.26%, and the average Frames Per Second (FPS) is 26.4 \(f/s\). Table 4 shows the specific performance of YOLOv4 on the test set when IoU is 0.5. The evaluation index mAP can effectively evaluate the recognition effect of the model. This parameter is composed of Precision and Recall. The definition of Precision and Recall is as follows. \[\text{Precision}=\frac{\text{TP}}{\text{TP}+\text{FP}} \tag{1}\]  
\[\text{Recall}=\frac{\text{TP}}{\text{TP}+\text{FN}} \tag{2}\]