## 2 Materials and Methods
### Using Three-Channel Attention Mechanism to Enhance Model Robustness  
Tomato leaf diseases pose several challenges, such as small disease targets, subtle differences between different types of diseases, and unclear disease features. To address these issues, we developed a three-channel attention mechanism module that enables the model to capture subtle disease features and focus on specific disease locations. This module effectively suppresses the negative impact of interfering information, such as leaves and background, on the model, which in turn enhances the model's robustness. The three-channel attention mechanism module, depicted in Figure 3, consists of a spatial attention module, a channel attention module, and a coordinate attention module, which are connected to produce the final output. The proposed three-channel attention mechanism is built on the idea of CBAM, which establishes interdependencies between channels and extracts location attention information through convolution. However, convolution can only capture local relationships and lacks the ability to extract long-distance relationships. To overcome this limitation, we added the coordinate attention mechanism to CBAM, enabling the model to encode horizontal and vertical location information into channel attention based on the time-channel relationship. This approach allows the mobile network to effectively attend to a wide range of location information without excessive computational effort. Moreover, it compensates for the drawback of the original CBAM by enabling the model to accurately locate and identify disease information in images without rapid degradation of the model's accuracy due to the complex environment, thus improving the model's robustness. The channel attention mechanism is an adaptive spatial region selection mechanism that selects the positions the model needs to focus on to obtain the specific location of the disease in the image. The channel attention mechanism weights the convolutional features of the channels, thereby enhancing the expression ability of the disease parts. The channel attention mechanism can be expressed as Equation (1), as shown in detail in Figure 4.  
The Spatial Attention Module is a channel compression technique that performs average pooling and max pooling separately in the channel dimension. Specifically, the MaxPool operation extracts the maximum value in the channel, with the number of extractions being the product of the height and width. Meanwhile, the AvgPool operation extracts the average value in the channel, with the number of extractions also being the product of the height and width. Subsequently, the feature maps extracted earlier (each with a single channel) are combined to obtain a 2-channel feature map that is utilized to  
Figure 4: Channel attention module. Figure 3: Diagram of the Three-Channel Attention Mechanism Structure. locate the specific position of the disease. The module structure is illustrated in Figure 5. The Spatial Attention Module can be mathematically expressed as Equation (2). \[Mc(F) =\sigma(MLP(AvgPool(F))+MLP(MaxPool(F)))\] \[=\sigma(W_{1}(W_{0}(F^{c}_{avg}))+W_{1}(W_{0}(F^{c}_{max}))) \tag{1}\]  
\[M\!s(F) =\sigma(f^{\gamma\times T}([AvgPool(F);MaxPool(F)]))\] \[=\sigma(f^{\gamma\times T}([F^{c}_{avg};F^{c}_{max};])) \tag{2}\]  
\[Yc(i,j)=Xc(i,j)\times G^{h}_{c}(i)\times G^{h}_{c}(j) \tag{3}\]  
The Coordinate Attention Module operates in three steps. First, the input feature maps are pooled in horizontal and vertical directions using 1D global pooling to generate two separate feature maps through aggregation. Next, the two feature maps with specific direction information are encoded to generate attention maps. Finally, the two attention maps are multiplied with the input feature maps to achieve the goal of emphasizing the coordinate information representation.