# Detection of _Camellia oleifera_ Fruit in Complex Scenes by Using YOLOv7 and Data Augmentation
## 3 Results and Discussion
### Comparison of Models  
The YOLOv7 model was compared with YOLOv5s, YOLO v3-spp and Faster RCNN networks to verify its accuracy and effectiveness [35]. All these models were established based on the same weights of COCO pre-training and parameters with YOLOv7 model, and the original dataset of _Camellia oleifera_ fruit was also used in the models. The comparison of mAP, Precision, Recall, F1 score and detection speed among different models is shown in Table 1. The Precision of YOLOv7 model was 0.4%, 4.51% and 34.86% higher than those of YOLOv5s, YOLO v3-spp and Faster RCNN models, respectively. The mAP of YOLOv7 model increased by 0.98%, 11.44% and 4.24% than those of YOLOv5s, YOLO v3-spp and Faster RCNN models, respectively. Compared with YOLOv5s and YOLO v3-spp, the Recall of YOLOv7 model increased by 3.95% and 5.63%, respectively. The Recall of Faster RCNN model was slightly higher than that of the YOLOv7 model, but the other indicators were significantly lower than those of the YOLOv7 model. The YOLOv7 model had the best F1 score of 93.67%. The detection time of the YOLO models were less than 0.1 s, and that of the YOLOv7 model was only 0.025 s. Faster RCNN is a two-stage target detection model, so the average detection time for a single image is 5.167 s, which is lower than that of the YOLO model. In summary, the YOLOv7 model had higher accuracy and efficiency than YOLOv5s, YOLO v3-spp and Faster RCNN models.  
The different models were used to detect the _Camellia oleifera_ fruit images on the test set to compare their generalisation ability (Table 2). The YOLOv7 model detected more objects than YOLOv5s, YOLO v3-spp and Faster RCNN models. At the same time, the missed and wrong objects of the YOLOv7 model were both less than YOLOv5s, YOLO v3-spp and Faster RCNN models. Figure 9 shows the detection results of different models in a variety of complex scenes in test set, in which the blue circle is wrong objects and the green circle is missed objects. From the representation images of the four scenes in Figure 8, YOLOv7 can successfully detect all _Camellia oleifera_ fruit in sidelight or slightly  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Target Detection** & **mAP (\%)** & **Precision (\%)** & **Recall (\%)** & **F1 Score (\%)** & **Average Detection Speed** \\
**Networks** & **mAP (\%)** & **Precision (\%)** & **Recall (\%)** & **F1 Score (\%)** & **(s/Image)** \\ \hline Faster RCNN & 91.50 & 59.35 & 93.59 & 73.00 & 5.167 \\ YOLO v3-spp & 84.30 & 89.70 & 87.50 & 86.90 & 0.072 \\ YOLOv5s & 94.76 & 93.81 & 89.18 & 91.44 & 0.054 \\ YOLOv7 & 95.74 & 94.21 & 93.13 & 93.67 & 0.025 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Performance comparison among different models.  
Figure 8: Training and validation loss.  
occlusion scenes. The YOLOv7 model produced less wrong objects and missed detection than the YOLOv5s, YOLO v3-spp and Faster RCNN models in the scene of backlight or heavy occlusion.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{**Objects Number**} & \multirow{2}{*}{
\begin{tabular}{c} **Number of** \\ **Actual Objects** \\ \end{tabular} } & \multicolumn{4}{c}{**Target Detection Networks**} \\ \cline{3-6}  & & **Faster RCNN** & **YOLO v3-spp** & **YOLO v5** & **YOLO v7** \\ \hline Number of detected objects & 1401 & 1426 & 1437 & 1577 & 1588 \\ Number of right objects & 1401 & 1256 & 1081 & 1308 & 1327 \\ Number of wrong objects & 0 & 170 & 356 & 269 & 261 \\ Number of missed objects & 0 & 145 & 320 & 93 & 74 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Detection result of different models.  
Figure 9: Examples of the detection results of four network models in a variety of complex scenes in test set. (**a**) sidelight angle; (**b**) backlight angle; (**c**) Slightly occlusion; (**d**) Heavy occlusion.  
The overall detection result of the YOLOv7 model was better than the current popular _Camellia oleifera_ fruit detection models. The YOLOv7 model has high accuracy and real-time detection performance to avoid wrong and missed detection.