# Lightweight Object Detector Based on Images Captured Using Unmanned Aerial Vehicle
## 2 Materials and Methods
### Methods
#### 2.2.3 Self-Weight Coordinate Attention  
Coordinate attention (CA), as a lightweight attention mechanism, combines positional information with channel information and incorporates it into channel attention to enhance the model's ability to capture long-distance dependencies. To improve the sensitivity of coordinate attention to spatial attention and the accuracy of detecting important objects at different locations, this study proposes an improved self-weight coordinate attention (SWCA). SWCA improves attention performance by merging feature maps in the width and height directions with additional convolution and sigmoid operations. The additional convolutional layer is used to transform parametric features to enhance the expression ability of attention weights, capture the dependence between adjacent positions, and correct the spatial information fragmentation problem caused by the pooling operation of the coordinate attention mechanism. The sigmoid activation function is applied to the feature map after convolution, and the value of each element of the feature map is compressed to between 0 and 1, which eliminates the dimensional difference of the original weights between different channels and positions and ensures that the attention module's intensity is comparable across spatial positions in order to generate attention weights. These attention weights calibrate regions differently--which would otherwise be attention weights--by additionally reflecting the importance of different positions, improving the attention weighting capacity of the model. The SWCA structural diagram is shown in Figure 5:  
Figure 4: Overall structure of Yolo-CFS (Yolo-C2f-Faster self-weight coordinate attention). The input feature map \(x_{c}\) is average-pooled along the horizontal and vertical coordinates to obtain feature maps \(z_{c}^{h}\) and \(z_{c}^{w}\), corresponding to the height and width, respectively. One can capture the long-range dependency of spatial directions and retain the precise position information of the other spatial direction, while the other can better help the network to locate the object of interest. The computational formulas are as follows:  
\[z_{c}^{h}=\frac{1}{W}\sum_{0\leq i<W}x_{c}(h,i) \tag{3}\]  
\[z_{c}^{w}=\frac{1}{H}\sum_{0\leq i<H}x_{c}(j,w) \tag{4}\]  
The height and width feature map extension channels are spliced, and the convolution operation is performed to obtain the feature map containing global information in both the height and width dimensions, as shown in Equation (5):  
\[f=\delta(Conv([z_{c}^{h},z_{c}^{w}])) \tag{5}\]  
where [*, *] denotes the concatenation along the spatial dimension, \(\delta\) denotes the nonlinear activation function, \(feR^{\frac{\zeta}{\tau}\times(H\times W)}\) is an intermediate feature map that encodes spatial information both horizontally and vertically, and \(r\) is a deceleration rate that controls the size of the block. Then, \(f\) is separated into two independent tensors \(f^{h}eR^{\frac{\zeta}{\tau}\times H}\) and \(f^{w}eR^{\frac{\zeta}{\tau}\times W}\) along the spatial dimension. Next, two 1*1 convolutions are used to change \(f^{h}\) and \(f^{w}\) into tensors with the same number of channels as the input x, as shown in the following:  
\[g^{h}=\sigma(Conv(f^{h})) \tag{6}\]  
\[g^{w}=\sigma(Conv(f^{w})) \tag{7}\]  
Figure 5: Structure of self-weight coordinate attention. where \(\sigma\) is the sigmoid function, and the outputs \(g^{h}\) and \(g^{w}\) are used as preliminary attention weights. After obtaining feature map \(f\), which contains global information with respect to both height and width dimensions, additional convolution and sigmoid operations are used to obtain \(f^{HW}\).