## 5 Experiment
### Experiment and Analysis of Target-Detection and Recognition Model  
The improved YOLOv7 model can effectively improve the quality of input images and reduce the influence of illumination factors on recognition. Adding an attention mechanism can improve the detection effect of small targets and the attention to practical features, reduce the computational pressure, and improve the recognition accuracy.  
To verify the actual detection effect of the proposed improved YOLOv7 model, the ablation experiment under the same conditions was carried out using the self-built dataset. The model evaluation indexes include precision (\(P\)), recall (\(R\)), mean average precision (\(mAP\)), floating-point operations per second (FLOPs), parameters, and the detection speed (FPS). The calculation formulas of \(P\), \(R\), and \(mAP\) are as follows.  
\[P=\frac{TP}{TP+FP} \tag{14}\]  
Figure 13: Experimental principle and flow chart.  
\[R=\frac{TP}{TP+FN} \tag{15}\] \[mAP=\frac{\sum\limits_{i}^{N}AP_{i}}{N} \tag{16}\]  
where _TP_ is the number of correct anchor rods detected, _FP_ is the number of other objects seen as anchor rods by mistake, _FN_ is the number of the right anchor rods detected as other objects by mistake, \(N\) is the number of detection categories, and _AP_ is the average accuracy of a single category. The IOU threshold is set to 0.5; that is, the average accuracy of the single category is _AP_\({}_{0.5}\), and the detection category \(N\) is one, so mAP = _AP_\({}_{0.5}\). The results of ablation experiments are shown in Table 3.  
The ablation experiment results show that model a is the 0.1 version of the original YOLOv7 model; model b adds the CLAHE algorithm to enhance the data based on model a, which reduces the influence of illumination conditions on the image. The _mAP_ is 1.8% higher than model a, indicating that CLAHE can significantly improve image clarity, thus improving the accuracy of anchor-rod recognition. Model c adds the CBAM based on model b. The number of parameters and FLOPs are reduced, and the _mAP_ is 3.5% higher than the original model. It is proven that the introduction of the CBAM makes the model pay more attention to practical features and filter out invalid information, which is of practical significance for improving the model's performance. Model d adds the BiFormer attention mechanism based on model b. Compared with the original model, _mAP_ is increased by 2.9%, and the number of parameters is also increased. This confirms that the BiFormer attention mechanism helps improve the detection ability of small targets but simultaneously increases the amount of calculation. Based on model d, the CBAM is added to the head network of model e, and the _mAP_ is 5.7% higher than that of the original model. At the same time, the increase in the number of parameters caused by the BiFormer attention mechanism is suppressed to a certain extent. The comparison of the detection effects of the original YOLOv7 model and the improved model is shown in Figure 14.  
The experimental results show that the target-detection model based on YOLOv7 + CLAHE + BiFormer + CBAM fusion has a good effect on anchor-rod recognition in low and uneven illumination environments. The _mAP_ is 5.7% higher than that of the YOLOv7 model, and the number of parameters is reduced by 2M, which has a significant improvement in detection accuracy.  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Subject** & **Model** & **Precision** & **Recall** & **mAP** & **FLOPs/G** & **Parameters/M** & **FPS** \\ \hline a & YOLOv7 & 90.2\% & 90.1\% & 89.2\% & 103.5 & 37 & 87.5 \\ b & CLAHE + YOLOv7 & 92.6\% & 93.8\% & 91.0\% & 103.5 & 37 & 87.5 \\ c & CLAHE + CBAM + YOLOv7 & 94.4\% & 93.5\% & 92.7\% & 102.1 & 35 & 128.3 \\ d & CLAHE + BiFormer + YOLOv7 & 94.0\% & 91.2\% & 92.1\% & 103.7 & 39 & 122.6 \\ e & YOLOv7 & 96.2\% & 94.7\% & 94.9\% & 105.8 & 35 & 123.2 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparison of ablation experiment results.