# YOLOv8-GO: A Lightweight Model for Prompt Detection of Foliar Maize Diseases
## 2 Materials and Methods
### Identification Method
#### 2.2.2 Global Attention Mechanism  
The attention mechanism algorithm originates from the field of natural language processing and mimics the cognitive functions people use to understand language content. Human vision also has two levels of attention cognition: the fovea of the human eye and the screening function of the brain. Consequently, the attention mechanism can play an important role in machine vision tasks.  
The essence of the attention mechanism is to amplify the propagation and calculation of important information in the subsequent network by assigning weights to the input information so that it has a greater impact on the final output. Focusing on the target, ignoring other unimportant information such as the background, and reducing the impact of unimportant information on the output can not only improve the recognition accuracy of the model and avoid missed detection but also accelerate the convergence of the model. The visual attention mechanism is generally based on the spatial attention mechanism and the channel attention mechanism, but the traditional attention mechanism often performs poorly in balancing and integrating channel and spatial information, resulting in unsatisfactory feature representation. The Global Attention Mechanism (GAM) solves this problem by considering both global context and local details at the same time [34].  
As illustrated in Figure 10 and represented by Equations (2) and (3), the feature map \(F1\) is input into the GAM, where it undergoes channel attention processing (denoted as _Mc_) to obtain \(F2\). Unlike traditional channel attention mechanisms that use global average pooling to generate channel attention maps, the GAM's channel attention mechanism employs a permutation operation to unfold the spatial dimensions and directly inputs them into a fully connected layer to derive the channel attention map. This approach retains more global and spatial information, which is also utilized to generate spatial attention maps, ensuring both globality and interactivity. Subsequently, \(F2\) is fed into the spatial attention module (denoted as _M_s), where spatial information is compressed through two \(7\times 7\) convolutions. The output is then smoothed using a Sigmoid function to produce the spatial attention map. Finally, the spatial attention map is multiplied with \(F2\) to obtain the final output feature map \(F3\).  
\[\text{F2}=\text{Mc (F1) }\otimes\text{F1} \tag{2}\]  
\[\text{F3}=\text{Ms (F2) }\otimes\text{F2} \tag{3}\]  
The GAM can make more use of global information to capture richer target information and adopt a relatively simple design. It can improve model performance without significantly increasing the computational cost and is more suitable for the improvement of lightweight networks. This paper added the GAM module in front of the SPPF layer, combined global attention and multi-scale pooling of the SPPF layer, and further optimized the receptive field, thereby improving the detection ability of complex backgrounds. Maize disease recognition must consider both relatively small spots and the overall distribution of spots on the leaves and treat the entire area with spots as the target. Therefore, multi-scale global information is also very important. Putting it in P3 will result in too much attention being paid to small targets, and due to the high resolution of the feature map, it will greatly increase the computational overhead, which is not conducive to light weight. Adding it to the Neck can also improve the ability to process multi-scale information, but it will  
Figure 10: Global Attention Mechanism structure diagram.  
also greatly increase the computational overhead. Therefore, adding it before the SPPF layer can not only improve the expression of global features and optimize the extraction of multi-scale information, but also result in high computational efficiency. Based on the previous analysis, this paper places the GAM module before the SPPF layer, as shown in Figure 11.