# A Pineapple Target Detection Method in a Field Environment Based on Improved YOLOv7
## 3 Results and Discussion
### The Results of Comparing the Detection Performance of the Proposed Network with Other Networks  
In order to prove the superiority of the model proposed in this paper, its performance was compared with YOLOv4-tiny, YOLOv5s, and YOLOv7. The data set used in this test was the whole test set. The test environment and data set remained unchanged. In order to achieve the best results for each model, the image input sizes of all models were 640 \(\times\) 640. Table 4 shows a comparison of the \(P\), \(R\), \(F1\), \(mAP\), and average detection time for the different models, the best result of each item is marked in bold. The model proposed in this paper achieved the best results in the four indicators of \(P\), \(R\), \(F1\), and \(mAP\), while the lightweight network YOLOv5s achieved the minimum average detection time. In terms of the \(P\), our model was 10.65%, 5.22%, and 2.90% higher than YOLOv4-tiny, YOLOv5s and YOLOv7, respectively; the \(R\) was 7.06%, 4.69%, and 3.41% higher, respectively. YOLOv5s was close to YOLOv7 in the detection performance, and YOLOv5s was slightly better in the detection speed. Our model was basically the same as YOLOv4-tiny, with an average detection time, but 4.21 and 2.98 ms slower than YOLOv5s and YOLOv7, respectively. The detection time of the four models was less than 25 ms, and our model traded an obvious detection performance improvement with less computation time. Compared with the other models, our proposed model had better detection accuracy, and the detection speed was also within a reasonable range. Therefore, compared with the other models, it is more suitable for pineapple detection in a complex field environment. The three cases of detection results are shown in Figure 11. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Model** & **P (\%)** & **R (\%)** & **F1 (\%)** & **mAP (\%)** &
\begin{tabular}{c} **Average Detection** \\ **Time (ms)** \\ \end{tabular} \\ \hline YOLOv4-tiny & 83.52 & 82.77 & 83.14 & 86.55 & 24.39 \\ YOLOv5s & 88.95 & 85.14 & 87.01 & 91.64 & **19.60** \\ YOLOv7 & 91.27 & 86.42 & 88.78 & 93.11 & 20.83 \\ Ours & **94.17** & **89.83** & **91.95** & **95.82** & 23.81 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Comparison of the proposed network with the other networks. The Results of the Comparison of the Detection Performances of the Proposed Network for Different Maturities of Pineapple  
In order to explore the differences in the detection performances between the proposed model and the original YOLOv7 model in detecting pineapples with different maturities, 40 pictures of pineapples with three maturities were selected from the test set for a detection performance test. The test results are shown in Table 5. It can be seen from Table 5 that the  
Figure 11: Comparison of the detection results of the four models on pineapples. (**a**) YOLOv4-Tiny; (**b**) YOLOv5s; (**c**) YOLOv7; (**d**) Ours. number of pineapples to be tested was 64 unripe pineapples, 73 semi-ripe pineapples and 75 ripe pineapples. Comparing the detection results of the model output with the labeled data of the picture, it can be seen that the improved model had better detection results for pineapples of three maturities compared with the original model. In order to further explore the differences between the improved model and the other models in the detection performance of pineapple with different maturities, the performance of the improved model was compared with YOLOv4-tiny, YOLOv5s, and YOLOv7. The data set used in the test was the whole pictures of the test set. The test results are shown in Figure 12. For YOLOv4-tiny, the lowest \(AP\) values were obtained for pineapples with three maturities. Among them, the \(AP\) value of unripe pineapple was the highest, higher than that of semi-ripe pineapple and ripe pineapple. This is because YOLOv4-tiny had a poor ability to distinguish mature and semi-mature pineapples, resulting in the simultaneous decline in the \(AP\) indicators of both.