## 3 Methods  
### YOLOv5 Object Detection Network  
YOLOv5 is the best overall performance target detection model in the YOLO architecture series. Currently, there are several variants of YOLOv5 (including n, s, m, x, and l). For simplicity, we used YOLOv5, which represents the standard version YOLOv5l in the following. As a single-stage detection model, YOLOv5 has high detection accuracy and fast detection speed. YOLOv5s can reach 140 frames per second on the GPU server of nvidia tesla V100. Compared withYOLOv4 [27], the training speed of the YOLOv5 model is faster, the weight file of the model is smaller, and it supports the batch processing of images. The model is developed based on the Pytorch framework, which can easily convert the Pytorch weight file to the Android ONXX format or iOS format, indicating that the YOLOv5 model is suitable for deployment on mobile devices and is easier to put into production environment. Therefore, the advantage of the YOLOv5 model lies in its high detection accuracy, light weight, fast detection speed, and easy deployment. The accuracy, real-time performance, and light weight of the fruit detection model are crucial to the recognition of citrus fruit in an orchard in the natural environment. This study attempts to base the detector of the YOLOv5 architecture to detect dense small citrus fruit. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Dataset** & **Varieties** & \begin{tabular}{c} **Image Resolution** \\ **(Pixels)** \\ \end{tabular}  & \begin{tabular}{c} **Number of** \\ **Original Images** \\ \end{tabular}  & \begin{tabular}{c} **Number of Images** \\ **after Augmentation** \\ \end{tabular}  \\ \hline \multirow{4}{*}{Citrus} & \ \begin{tabular}{c} Kumquat \\ Nanfeng tangerine \\ Fertile tangerine \\ Shatang tangerine \\ \end{tabular}  &
\begin{tabular}{c} 1280 \(\times\) 720 \\ 1280 \(\times\) 720 \\ 1280 \(\times\) 720 \\  
As shown in Figure 3, the YOLOv5 framework includes three parts: the backbone network, neck network, and detection network. The function of the backbone network is to extract feature maps from the input image by multiple convolutions and merging. As shown in Figure 3, a three-layer feature map was generated in the backbone network. Their sizes were: 80 \(\times\) 80, 40 \(\times\) 40, and 20 \(\times\) 20. The neck network mainly fuses the feature maps of different scales generated by the backbone network to output a new enhanced feature map to obtain more contextual information and reduce the loss of information [28]. In the merging process, the characteristic pyramid structure of FPN and PANet is adopted. Strong semantic features are transferred from the top feature map to the bottom feature map by the FPN structure. At the same time, strong localization features are also transferred from lower feature maps to higher feature maps by using PANet. FPN and PANet, hence together, enhance the feature fusion ability of the neck network. Finally the detection network is used to provide the detection result. The detection network of YOLOv5 consists of three detection layers, with an output feature map of 80 \(\times\) 80, 40 \(\times\) 40, and 20 \(\times\) 20, which is used to detect objects in the input image. Each detection layer ultimately outputs a 21-channel vector and then generates and marks the predicted bounding box and category of the target in the original input image to achieve the detection and classification of the final targets. In this architecture, the Focus module slices and connects images. This module aims to reduce the number of model calculations and speed up training. First, it uses a slice operation to divide the input 3-channel image into four slices. Second, a concat operation is used to deeply connect the four slices, and then a convolutional layer is used to generate the output feature map, as shown in Figure 4a. CBL is a standard convolutional layer, which is composed of convolution, normalization and SiLU activation function modules, as shown in Figure 4b.