# A Practical Deep Learning Architecture for Large-Area Solid Wastes Monitoring Based on UAV Imagery
## 3 Methods
### Segmentation Model
#### 3.2.2 Context Feature Branch  
In high-resolution imagery, the overall visual interpretation characteristics of solid waste include: first, solid waste is prone to be confused with background elements such as buildings and roads; second, solid waste is deeply integrated into the background and often distributed within other land-use types, especially open spaces and lawns. Its identification relies on specific contextual information. To address these two issues, we designed a global semantic module block (GSM Block). This block enables the model to extract global contextual features, which refer to the information across the entire image and are used to understand the relationship between the target object and its surrounding environment. Additionally, it facilitates the extraction of solid waste from the background using an attention mechanism. As a result, the model gains the ability to effectively distinguish solid waste from other elements in the image.  
The squeeze block, designed in this paper, is used to perform global feature condensation (Figure 5). The input feature IN \(\in\) R\({}^{H\times W\times C}\) is divided into three parts: q = \(W_{q}\)in, k = \(W_{k}\)in, v = \(W_{v}\)in. Where, \(W_{q}\in\) R\({}^{C_{q}\times C}\), \(W_{k}\in\) R\({}^{C_{k}\times C}\), and \(W_{v}\in\) R\({}^{C_{q}\times C}\) are learnable weights. \(x^{\downarrow(h,w,c)}\) represents the transformation of tensor x to dimensions (h,w,c), \(w\) denotes a vector with all elements being 1.  
Figure 4: Backbone and segmentation head of the SWM.  
Figure 5: Squeeze Block of SWM.  
Global features are obtained by performing dimension transformation and taking the mean along the horizontal and vertical directions of tensor q. The formula for calculating the mean along the horizontal direction is:  
\[\text{q}_{h}=\left(q^{\downarrow(C_{q},H,W)}1^{W}\right)^{\downarrow(H,C_{q})}/w \tag{1}\]  
The formula for calculating the mean along the vertical direction is:  
\[\text{q}_{w}=\left(q^{\downarrow(C_{q},W,H)}1^{H}\right)^{\downarrow(W,C_{q})}/H \tag{2}\]  
Similarly, applying this set of formulas to tensors k and v, we obtain the horizontal mean values k\({}_{h}\) and v\({}_{h}\), as well as the vertical mean values k\({}_{w}\) and v\({}_{w}\). Next, the compressed feature maps are multiplied together to obtain a H \(\times\) W \(\times\) C feature map. Then, the product is element-wise multiplied with the input feature to weight the correlations between different dimensions.  
After completing the global feature condensation, we need to enhance attention by introducing global attention extraction. \(P_{i,j}\) represents a position on the feature map:  
\[P_{i,j}=\sum_{1}^{H}softmax\left(\text{q}_{h}\text{\textasciitif{T}}  
row and \(j\)-th column of the \(c\)-th channel in the output feature map, and \(C_{in}\) represents the number of channels in the input feature map. The deformable separable convolution function can be represented as:  
\[P_{i,j}^{c}=\sum_{1}^{C_{in}}\left(W_{k}^{c}\cdot x_{p_{k}^{T}+i,p_{k}^{T}+j}^{ \prime}\right) \tag{4}\]  
For each position in the input feature map, the designed DCR adjusts the sampling position of the convolution kernel based on the offset at that position, introducing positional variability. This allows the model to better adapt to the deformation of solid waste, thereby improving the model's ability to handle the complex structures and irregular shapes of solid waste.