# 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 DeepLab V3+ [19] encoder incorporates null-space pyramid pooling with the Xception network [20] as the feature extraction network. Depth-separable convolution was introduced for improvement within the ASPP (Atrous Spatial Pyramid Pooling) module. A multigrid method with different expansion rates was employed by the encoder across the three convolutions. The resulting image-level features were fed into a 1 \(\times\) 1 convolution of 256 filters and batch-normalized [21]. The decoder module was designed to establish connections between low-level and high-level features. A depth-separable convolution was  
Figure 3: Original and labeled images. (**a**) Original image; (**b**) labeled image. Figure 2: Overall flow chart of the variable-spray system. also applied in the decoder part. The feature layer obtained from the output of the encoder (high-level features, with an outstride of 16) emerged after four-fold bilinear upsampling with the feature layer corresponding to the same resolution in the encoder (low-level features, with an outstride of 4) after \(1\times 1\) product dimensionality reduction. Subsequently, 3 \(\times\) 3 convolutional refinement was performed, followed by another four-fold bilinear upsampling to obtain the prediction results at the original image resolution [22; 23]. The Xception model was constructed from a linear stack of deeply separable convolutions with residual connections. It consisted of an Entry flow, a Middle flow that is repeated 16 times, and an Exit flow [24]. The Xception network architecture is illustrated in Figure 4. After batch normalization, a \(1\times 1\) convolution was performed, and the channels were downscaled to obtain the output of the encoder part. However, the features in the Entry flow in the Xception component were not sufficiently downsampled and had a high resolution. Additionally, the Entry flow contained a large number of channels, leading to substantial GPU memory consumption. As a consequence, Xception incurred heavy computational demands and consumed considerable time [25]. Variable-spraying systems require real-time sensing of the environment to quickly implement spray control decisions. However, the Xception network suffers from a large memory footprint and high computational requirements, resulting in a slow detection speed. It is unable to meet the requirements for use on the devices of variable-spray control systems. Figure 4: Xception network structure diagram. (**a**) Input stream; (**b**) Intermediate stream; (**c**) Output stream. Therefore, the lightweight MobileNet V2 network [26] was selected in this study as the backbone network of the DeepLab V3+ semantic segmentation model for feature extraction. The MobileNet V2 network architecture is illustrated in Figure 5.  
The MobileNet V2 network mainly employs depthwise separable convolutions and introduces the inverted residual structure and the linear bottleneck structure. In the structure of the residual proposed by Resnet [27], the dimension reduction was first achieved using \(1\times 1\) convolution, followed by \(3\times 3\) convolution, and finally, dimension uplift through \(1\times 1\) convolution. In the inverted residual structure of MobileNet V2, the order of dimension reduction and uplift was reversed, and the \(3\times 3\) convolution was replaced with the \(3\times 3\) DW convolution. The linear bottleneck layer design of MobileNet V2 consists of depthwise separable convolutions and inverted residual structures. As shown in Figure 5, when stride = 1, the input first expands the number of channels through a \(1\times 1\) convolution, with RelU6 as the activation function; then, it passes through a \(3\times 3\) depthwise convolution with RelU6 as the activation function, and after the number of channels is compressed back by \(1\times 1\) pointwise convolution, the activation function is linear. Finally, the shortcut is used to add the two results together.