# Study on Lightweight Model of Maize Seeding Object Detection Based on YOLOv7
## 3 Results and Analysis  
### Experimental Environment and Evaluation Indicators  
The training task is implemented on Python 3.9 and Pytorch 1.13. The device information required for training includes Inter(R) Core(TM) i9-10980 XE CPU @ 3.00 GHz, NVIDIA GeForce RTX 3090, and 64 GB of memory. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Module Name** & **Input** & **Output** & **Filter Size** & **Layers** \\ \hline CBS & 640 \(\times\) 640 \(\times\) 3 & 640 \(\times\) 640 \(\times\) 32 & 1 & 0 \\ CBS & 640 \(\times\) 640 \(\times\) 32 & 320 \(\times\) 320 \(\times\) 64 & 2 & 1 \\ CBS & 320 \(\times\) 320 \(\times\) 64 & 320 \(\times\) 320 \(\times\) 64 & 1 & 2 \\ CBS & 320 \(\times\) 320 \(\times\) 64 & 160 \(\times\) 160 \(\times\) 128 & 2 & 3 \\ GhostELAN & 160 \(\times\) 160 \(\times\) 128 & 160 \(\times\) 160 \(\times\) 256 & 1 & 4–12 \\ GhostMP & 160 \(\times\) 160 \(\times\) 256 & 80 \(\times\) 80 \(\times\) 256 & 2 & 13–17 \\ GhostELAN & 80 \(\times\) 80 \(\times\) 256 & 80 \(\times\) 80 \(\times\) 512 & 1 & 18–26 \\ GhostMP & 80 \(\times\) 80 \(\times\) 512 & 40 \(\times\) 40 \(\times\) 512 & 2 & 27–31 \\ GhostELAN & 40 \(\times\) 40 \(\times\) 512 & 40 \(\times\) 40 \(\times\) 1024 & 1 & 32–40 \\ GhostMP & 40 \(\times\) 40 \(\times\) 1024 & 20 \(\times\) 20 \(\times\) 1024 & 2 & 41–45 \\ GhostELAN & 20 \(\times\) 20 \(\times\) 1024 & 20 \(\times\) 20 \(\times\) 1024 & 1 & 46–54 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Network architecture of the backbone. Figure 10: Improved model structure of LW-YOLOv7. During training, we need to calculate the size of the anchor boxes so that the model can better predict the bounding boxes of maize seedlings. K-means is an unsupervised learning algorithm. It treats all the bounding boxes in the training set as samples and takes the width and height of the bounding boxes as two features. During calculation, we set the number of anchor boxes to 9 and use the new distance calculation equation. The new calculation method is shown in Equation (16). Secondly, for each sample in the training set, calculate its distance from all cluster centers and assign it to the nearest cluster. For each cluster, recalculate the center point of the cluster; that is, select the average value of all samples in the cluster as the new cluster center. Finally, K-Means perform 1000 epochs of iteration to obtain the optimal anchor boxes on the above operations. In deep learning, excessive input image resolution may lead to issues such as insufficient memory and long calculation time. Therefore, we set the image resolution to 640 \(\times\) 640. Additionally, when we were training maize seedlings data, the training results tended to stabilize at 80 epochs. To solve the problem of overfitting, we set the total number of iterations to 100. The learning rate is a very important hyperparameter in deep learning, which controls the speed of updating model parameters during gradient descent optimization. If the learning rate is too large, it may lead to the model cannot converge and large fluctuations in training error. Therefore, we set the initial learning rate to 0.01, the learning rate frequency to 0.1, and the final learning rate to 0.001. In YOLOv7, establishing the batch size has a significant impact on the training effect and speed of the model. Batch size refers to the number of samples processed simultaneously in each round of gradient descent, which can affect multiple aspects such as the direction, amplitude, and speed of model parameter updates. A larger batch-size value can improve the training speed of the model, but it may lead to overfitting, and an inability to converge, among other issues. Therefore, we set the batch size to 16. We also provided other hyperparameters and information during the training process. Table 3 shows the parameters of the training process. \[\text{Distance = 1 - IoU(box, centroid)} \tag{16}\]  
To assess the performance of the improved model, we use five evaluation metrics, including precision, recall, mAP, parameter, and FPS.