# Potato Leaf Disease Segmentation Method Based on Improved UNet
## 2 Materials and Methods
### Methods
#### 2.2.3 SE Attention Mechanism  
The core idea of the SE module lies in first performing a squeeze operation on the feature maps obtained through convolution to capture global features across the entire channel hierarchy. Subsequently, through the excitation operation, the model learns relationships between different channels and derives weights for each channel [25]. Finally, these weights are applied to the original feature maps of potato leaf disease spots to obtain the ultimate feature maps, with the output size of potato leaf images remaining unchanged. In practice, the SE module operates on the channel dimension by performing attention or gating operations. It expands the feature maps, originally in a low-dimensional space, to a higher-dimensional space using fully connected layers and recalculates the weights for each feature map. These weights are then aggregated to construct a distribution reflecting the importance of feature maps, as illustrated in Figure 6 of the SE attention mechanism. Different colors represent various values used to assess the importance of channels. The SE attention mechanism enables the network to adaptively select and strengthen important feature channels of potato leaf disease spots while suppressing unimportant ones, thereby improving the network's ability to represent input data features more distinctly. Moreover, given the small and diverse morphology of potato leaf disease spots, traditional feature extraction methods can negatively impact segmentation results. \[Z_{c}=F_{sq}(u_{c})=\frac{1}{H\times W}\sum_{i=1}^{H}\sum_{j=1}^{W}u_{c}(i,j) \tag{1}\]  
The squeeze operation effectively entails a form of global average pooling on the feature maps. Applying the squeeze operation to a feature map with c channels and an \(H\times W\) size compresses the map into a c-channel of 1 \(\times\) 1 size. During this process, the information in the original feature map is compressed into a representation that encapsulates global information. The squeeze operation achieves this by employing global average pooling, aggregating channel information from the original feature map into a single channel. Each channel retains only one average value, which encapsulates the global information of the entire feature map. \[\mathbf{s}=F_{ex}(z,W)=\sigma(g,(z,W))=\sigma(W_{2}\delta(W_{1}z)) \tag{2}\]  
In this context, \(\delta\) represents the ReLU (rectified linear unit) function. Figure 6: SE structure. The excitation operation essentially involves two fully connected layers. Firstly, it performs a fully connected operation on the global pooling result obtained through the previous squeeze operation (which can already be considered as a C-dimensional vector). This operation yields a C/r-dimensional vector, followed by the application of a ReLU activation function. Subsequently, this C/r-dimensional vector undergoes another fully connected operation, restoring the vector dimension to C, and is then passed through a sigmoid activation function (ensuring that the values range between 0 and 1) to obtain the final weight matrix. Throughout this process, critical channel features receive higher weighting, while less important channel features receive lower weighting. Ultimately, the channel features are multiplied by their respective weights and combined with the output of the SE module. In the SE block, the transformed feature maps are considered as the non-identity branch of the residual module. Both the squeeze and excitation operations are performed before the summation with the identity branch of the residual module. As networks tend to overfit during training, resulting in suboptimal segmentation performance on the test set, the SE attention mechanism is introduced into ResNet50 to alleviate the impact of overfitting. The network structure is depicted in Figure 7. The core idea of the ResNet module is to learn the residual between the input and output, denoted as H(X-X).