# Tree Seedings Detection and Counting Using a Deep Learning Algorithm
## 2 Materials and Methods
### Methods  
#### 2.2.1 YOLOv5 Network Architecture  
YOLOv5 is a single-stage object detector with four versions: YOLOv5s, YOLOv5m, YOLOv5l, and YOLOv5x [23; 24]. YOLOv5x has the highest detection accuracy and the largest width and depth, whereas YOLOv5s is considered the fastest and smallest width and depth model among other models. All versions of the YOLOv5 network have the same network architecture, but the difference is in model widths and depths. The main architecture of YOLOv5's four versions consist of three main parts: model backbone, model neck, and model head. YOLOv5 was designed to extract high-level features, reduce the processing time of the models, and preserve high accuracy [25]. In this paper, YOLOv5s was selected for tree seedlings detection not only due to its eligibility and fitness to effectively realize the requirements of tree seedlings detection task but also because it can be well deployed in agriculture and forest fields. YOLOv5s uses feature pyramids, which help the model to identify and match different sizes and scales of the same type of object [26]. Thus, YOLOv5s can detect different sizes of tree seedlings. Moreover, the feature map at the top layer of the pyramid can also have the advantage of the rich location information that is brought by the bottom layer and accordingly improves the model's accuracy [27]. Figure 5 shows the structure of the YOLOv5s. Figure 4: Examples of the data augmentation dataset. The model backbone of YOLOv5s is mainly used to extract essential features of the input image. It primarily consists of a focus module (Focus), standard convolution module (Conv), cross stage partial network module (C3), and spatial pyramid pooling module (SPP). The input RGB image is divided into four parts and concatenated by the focus module for better extracting the features during down-sampling. Then, the four parts of data are spliced in the channel dimension by the Concat module and then convolved to obtain the down-sampling feature map. The focus module increases the channel dimension and reduces the width and height of the feature map, improving the network's performance by lowering FLOPS (floating point operations per second) and increasing speed. Figure 6 shows the slicing operation of the Focus module. The Conv is the basic convolution module of YOLOv5s that performs convolution operation, normalization, and activation operations for feature extraction. The C3 module is a designed module based on cross stage partial network, which is used to enhance the gradient values of backpropagation between layers and improve the learning ability of the model. Figure 7 shows the structure of the C3 module. The SPP module improves the receptive field of the network by converting the arbitrary feature map into a fixed-size feature vector. It mixes and pools spatial features through three parallel max pooling layers and then concatenates them [28]. Figure 8 shows the structure of the SSP module. The model neck of YOLOv5s is composed of a series of path aggregation networks (PANets) [29], which can obtain FPN (feature pyramid networks) by assembling feature maps from different stages of the model backbone. The critical role of FPN is to enhance the semantic information by performing continuous down-sampling, which transfers the strong semantic features from the top feature maps into the lower feature maps. Whereas the PANets improve the accuracy of localization signals in lower layers by moving strong localization features from lower feature maps into higher feature maps, producing a noticeable enhancement of the location accuracy of the object [30]. The PAN and the FPN jointly strengthen the feature fusion capability and help the model to identify and match the different sizes and scales of the same target object. Figure 5: The structure of YOLOv5s. The model head of YOLOv5s is the final detection part of the model. It is composed of three detection layers that have different size feature maps. Moreover, it has been designed based on PANet, which is same as that of YOLOv3 and YOLOv4.