# Design and Experiment of Variable-Spray System Based on Deep Learning
## 2 Materials and Methods
### Semantic Segmentation Model for Wheat Weeds Based on DeepLab V3+
#### 2.2.2 Improved DeepLab V3+ Segmentation Model
The feature graph compressed by \(1\times 1\) convolution is concatenated with the input as the next bottleneck block. When stride = 2, the input and output feature map sizes are different; thus, the shortcut connection is not utilized. As the depth of a neural network increases, the vanishing gradient problem tends to occur. The inverted residual structure can effectively alleviate this problem. Therefore, when the network layer number is shallow, MobileNet V2 uses a bottleneck block without residuals, where the stride is set to 2. As the number of network layers increases, MobileNet V2 uses a bottleneck block with residuals to alleviate the phenomenon of disappearing gradients, where the stride is set to 1. The linear bottleneck structure improves the nonlinear representation of the network by introducing extension and projection layers, enabling the model to better capture complex features in the input data while reducing computational cost. By restricting the dimensions and the quantity of parameters involved in the convolution operation, the  
Figure 5: MobileNet V2 network architecture diagram. model's lightweight and high efficiency was maintained. The overall parameter count and computational demand of the model were reduced by the MobileNet V2 network. This enhancement can boost the speed of semantic segmentation and is well-suited for deployment on mobile devices. Due to the diverse background of weeds and wheat growth in fields, the model can focus on extracting weed features from the images by adding an attention mechanism, thereby reducing the interference of environmental factors. In this study, the CA attention module [28] was incorporated into the encoder part of DeepLab V3+, which ran in parallel with the ASPP. The encoder was optimized by splicing the outputs of the two parts and adjusting the number of channels. This optimization enhanced the model's ability to segment the details of weed edges, thereby improving overall segmentation performance and accuracy. The structure of the CA attention network is shown in Figure 6. The CA attention network decomposed channel attention into two one-dimensional feature-encoding processes, each of which aggregated features along two spatial directions [29]. The resulting feature maps were then encoded as a pair of directional and positional attention maps, respectively. This can be used as a complement to the input feature maps to improve the representation of the attentional object. In the improved DeepLab V3+ model, the lightweight MobileNet V2 network model was used to replace the original Xception network with large parameters as the backbone network, which reduced the parameter count of the model and addressed issues of spatial details loss and insufficient feature extraction. The CA attention module was introduced, and it was added in parallel with the ASPP after the feature extraction network, which enhanced the network's ability to capture global contextual feature information and improved the model's segmentation accuracy of the edges of weeds. The structure of the improved model is depicted in Figure 7.  
Figure 6: Coordinate Attention structure diagram.