# Occluded Pedestrian Detection Techniques by Deformable Attention-Guided Network (DAGN)
## 3 Deformable Attention-Guided Network (DAGN)
### Deformable Convolution with Attention Module (DCAM)  
To augment the network capability of adapting to various appearances and poses of pedestrians, we designed the deformable convolution with attention module (DCAM), motivated by the deformable ConvNet v2 (DCNv2) [10] and simplified NL block [34]. The deformable convolution module enhances the capability of handling geometric transformation. To achieve the best trade-off between the performance and the efficiency, we just apply the DCAM at the conv4 and conv5 stages to minimize the computational cost. We designed the deformable convolution module based on DCNv2 [10]. Based on the preceding feature map, the offsets are learned by the deformable convolution layer to enable the non-rigid deformation of the sampling region. For each location \(p\) with sampling grid \(N\), \(x(p)\) is the input feature map and \(y(p)\) is the output feature map. The deformable convolution module is defined with Equation (1):  
\[y(p)=\sum_{p_{n}\in N}\omega_{n}\cdot x(p+p_{n}+\Delta p)\cdot mask \tag{1}\]  
where \(\omega_{n}\) denotes the weight for the \(n\)-th location, \(p_{n}\) enumerates the locations in sampling grid \(N\), and \(\Delta p\) is the offset value of \(p_{n}\). Thus the sampling is on the non-rigid locations  
Figure 3: The architecture of our proposed deformable attention-guided network (DAGN) for pedestrian detection. The baseline detector is the cascade R-CNN [31] with the structure of feature pyramid networks (FPN) [32]. C3 to C5 denote the feature maps of the corresponding conv3 to conv5 stages of the ResNet50. The improved parts in our method are highlighted in red color. of \(p_{n}+\Delta p\). A mask branch is designed by a sigmoid layer to decide whether to perceive signals from particular regions. The scalar _mask_ lies in the range [0,1], \(\Delta p\) and _mask_ are learnable values. Figure 4a shows the structure of the DCAM which is built in the conv5 stage of the ResNet50. For the conv4 stage, the kernel sizes and strides are kept the same, while the number of filters is halved. We replace the original convolution layer with the deformable convolution module to generate geometric transformation-invariant features. The deformable convolution module is denoted with the green dotted line in Figure 4a. To further strengthen the global context information of the instances with different scales and deformed appearances, we incorporate the NL block with the deformable convolution module. Among the diverse self-attention mechanisms, such as squeeze-and-excitation (SE) [35], NL [36], global context (GC) [34], and convolutional block attention module (CBAM) [37], the NL block is superior for the pedestrian detection task. The NL block aims at capturing the dependency between two positions of a feature map in the spatial domain. These dependencies form the global context information to distinct the instance from the background. Other attention modules generate attention maps from the spatial domain, channel domain, and mixed domain. However, redundant information would weaken the discriminative ability of features, especially for the detection of small-scale instances. Therefore, the NL block is incorporated in our model to capture the context dependency information. Due to the expensive computational cost of the original NL block, we adopt the simplified version of the NL block [34], as shown in Figure 4b. At first, a linear transform matrix (\(1\times 1\) convolution) is introduced for global context modelling, followed by a SoftMax function to get attention weights. Then attention weights are applied to feature maps by using matrix multiplication to obtain the attention map. Next, we capture the global context dependency between the present position and all other positions using the above steps for each position. Then attention maps are transformed with a \(1\times 1\) convolution. Finally, the broadcast element-wise addition is employed to fuse the attention map with the feature for each position.