# BCS_YOLO: Research on Corn Leaf Disease and Pest Detection Based on YOLOv11n
## 2 Materials and Methods
### Proposed Model: BCS_YOLO
#### 2.2.1 SPCGA Module  
In corn leaf disease and pest detection, accurately identifying early appeared lesions and tiny insects is key to achieving early prevention and control. To further capture meaningful disease and pest context information in spatial and channel dimensions, this study proposes a novel attention mechanism called SPCGA. The structure of the corresponding SPCGA module, utilized by the proposed model, is shown in Figure 3. This module integrates global spatial and channel information and globally aggregates multi-scale features, thus enhancing the model's capacity for detailed feature extraction. It also utilizes the transformer self-attention mechanism (TSA) to strengthen global context modeling ability, reduce information attenuation, and improve the network's discrimination ability in complex backgrounds. Unlike traditional attention mechanisms that only focus on spatial or channel domains, the SPCGA module adaptively coordinates multiple attention paths to capture comprehensive feature representations. The SPCGA module processes input feature maps through three parallel attention branches. In the first branch, a channel attention (\(CA\)) mechanism generates channel weights by modeling inter-channel dependencies. This process suppresses redundant channels and emphasizes key signals at the initial level, effectively capturing local features of lesions and insects. The operation of the \(CA\) branch can be expressed as follows:  
\[M_{CA}(X)=\sigma(f_{CA}(AvgPool(X))+f_{CA}(MaxPool(X))) \tag{1}\]  
where \(X\) denotes the input feature map, \(\sigma\) denotes the sigmoid activation function, and \(f_{CA}\) denotes using first a convolutional layer to reduce dimensions, then a ReLU activation function, and finally a convolutional layer to restore the original dimensions. The \(CA\) branch uses both average pooling \((AvgPool)\) and max pooling \((MaxPool)\) operations simultaneously, which aggregates feature dimension information and enhances the effectiveness of feature representation. The \(CA\) feature map calculation is performed according to the following formula:  
\[X_{CA}=X\odot M_{CA}(X) \tag{2}\]  
where \(\odot\) denotes an element-by-element multiplication. Figure 3: The newly designed SPCGA module, utilized by the proposed BCS_YOLO model. The second branch of the SPCGA module utilizes a Global Spatial Attention (GSA) mechanism to enhance the model's ability to express global spatial information in feature maps. The GSA branch characterizes the feature associations between each position and all other positions. It generates spatial attention maps by calculating relationships between each position and all other positions. This allows to effectively capture global spatial context information of corn leaf diseases and pests. The output of the GSA branch is obtained using the following weighted summation:  
\[X_{GSA}=\gamma\cdot\sum_{j=1}^{N}\left(\frac{exp\Big{(}M_{i}\cdot N_{j}^{T} \Big{)}}{\sum_{j=1}^{N}exp\Big{(}M_{i}\cdot N_{j}^{T}\Big{)}}\bullet W_{j} \right)+X \tag{3}\]  
where \(\gamma\) denotes a learnable parameter initialized to zero; \(M_{i}\) denotes the query feature map, generated by a query convolution, representing the feature pattern that each spatial position wants to search for; \(N_{j}\) denotes the key feature map, generated by a key convolution, representing the feature information that each spatial position can provide; \(W_{j}\) denotes the value feature map, generated by a value convolution, representing the feature content actually transmitted by each spatial position; and \(N_{j}^{T}\) denotes the transpose of the key feature map, so that the query feature can be dot-produced with the key feature to calculate the correlation between spatial positions. To compensate for the insufficient model expressiveness of cross-channel and cross-spatial attention, the third branch of the SPCGA module adopts Transformer Self-Attention (TSA). TSA further captures global dependencies through scaled dot-product attention.