# Study on Lightweight Model of Maize Seeding Object Detection Based on YOLOv7
## 2 Materials and Methods
### Lw-Yolov7
#### 2.3.1 Improvement of Backbone  
In YOLOv7, a significant computational bottleneck arises from the CBS (Convolution, BN, SiLU) modules. These modules have high computational demand and require substantial memory space during training, posing challenges for deploying the model on resource-limited mobile devices. To address this issue, we integrate the GhostNet [41] model into YOLOv7. The GhostNet model, as shown in Figure 4, employs a two-step process to reduce computational complexity. Firstly, it utilizes ordinary convolutions with a kernel size of \(1\times 1\) to obtain intrinsic feature maps. These convolutions help capture essential information and reduce the dimensionality of the features. Secondly, GhostNet employs cheap operations to generate redundant feature maps based on intrinsic features. These redundant feature maps provide additional information without significantly increasing computational costs. By concatenating the intrinsic and redundant feature maps, GhostNet achieves better performance in object detection while minimizing computational costs. This approach effectively addresses the computational limitations of CBS modules, making it more feasible to deploy the model on resource-limited mobile devices. While GhostNet helps reduce the number of parameters in the backbone of YOLOv7, it may also lead to the omission of important features. To solve this issue, we have explored the integration of attention modules. Among them, the CBAM (Convolutional Block Attention Module) [42] has demonstrated the most promising results in terms of detection accuracy within our model. The CBAM, depicted in Figure 5, combines channel attention and spatial attention mechanisms to enhance the model's ability to capture informative features. CBAM is a lightweight and effective attention module for feed-forward convolutional neural networks. It includes two sub-modules: channel attention module (CAM) and spatial attention module (SAM). The CAM and SAM models can be viewed in Figure 6. Firstly, the input feature map \(\text{F}(F\in R^{c\times h\times w})\) was processed through a one-dimensional convolutional operation of CAM, and the result \(\text{M}_{\text{c}}(M_{c}\in R^{c\times 1\times 1})\) was multiplied with the input feature F. Secondly, by using the output result of CAM as channel-refined feature F', a two-dimensional convolution operation of the SAM was conducted. Finally, the result \(\text{M}_{\text{s}}(M_{s}\in R^{1\times h\times w})\) was multiplied with the CAM output to obtain the final result \(\text{F}^{\prime\prime}(F^{\prime\prime}\in R^{c\times h\times w})\). Figure 4: GhostNet. Conv represents an ordinary convolution with a \(1\times 1\) kernel size while \(\Phi_{1}\) represents a sequence of linear transformations. It operates on each channel, and its computational cost is much lower than ordinary convolution. The convolutional kernel size of cheap operation is \(5\times 5\). Figure 5: Convolutional Block Attention Module. The attention-generating process of the CBAM are shown in Equations (1) and (2),  
\[F^{\prime}=M_{c}(F)\otimes F \tag{1}\]  
\[F^{\prime\prime}=M_{c}(F^{\prime})\otimes F^{\prime} \tag{2}\]  
where \(\otimes\) denotes element-wise multiplication. M\({}_{\rm c}\) represents a one-dimensional convolution operation of CAM, while M\({}_{\rm s}\) represents a two-dimensional convolution operation of SAM. F denotes the input feature, and F\({}^{\prime\prime}\) denotes the output feature. By introducing GhostNet and CBAM modules, we have made changes to the structure of ELAN and MP, as shown in Figure 7. Compare with the original network, the new network decreases the number of parameters and is more suitable for deployment in mobile devices with limited mobile resources. Additionally, it also can improve its feature extraction capability by introducing the CBAM module and solving the problem of easily ignoring small maize seedlings in complex field environments. Figure 6: Sub-modules of CBAM. (**a**) Channel Attention Moule; (**b**) Spatial Attention Module.