# A Pedestrian Detection Network Based on an Attention Mechanism and Pose Information
## 3 Methodology  
The two main challenges encountered in pedestrian detection are as follows: first, the many instances of local occlusion in images lead to missed detections; second, images may contain numerous indistinguishable negative samples, such as similar vertical structures, resulting in false detections. We developed a new pedestrian detection method that integrates an attention mechanism with visual and pose information.  
As shown in Figure 2, the pedestrian region proposal network was designed based on existing detectors (such as ALFNet [29] and FCOS [49]), with the aim of generating a large number of candidate bounding boxes. The pedestrian recognition network is used to refine the confidence scores of proposal regions and remove challenging negative samples. For a given proposal region, the visual feature and pedestrian pose modules extract feature descriptions and pose feature descriptions, respectively. The pedestrian attention module extracts attention information as a complement to pose descriptions. The classification module is responsible for fusing these three feature descriptions and generating an embedded representation that can distinguish a pedestrian from the background.  
The pedestrian region proposal network is optimized using a multitask loss function:  
\[L_{rpn}=\sum_{i}L_{cls}(p_{i},p_{i}^{*})+\mu\sum_{i}p_{i}^{*}L_{reg}(t_{i},t_{i}^ {*}), \tag{1}\]  
where \(L_{cls}\) is the binary cross-entropy loss used to judge whether the candidate proposal region contains a pedestrian object and \(L_{reg}\) is the regression loss for pedestrian object localization. The coefficient \(\mu\) is used to balance the classification loss \(L_{cls}\) and the regression loss \(L_{reg}\). We define \(p_{i}\) as the predicted probability and \(p_{i}^{*}\) as the ground-truth label. \(p_{i}^{*}\) is set to 1 only when the IoU between candidate box i and any ground-truth box is larger than 0.5; otherwise, \(p_{i}^{*}\) is set to 0 as the background. As such, the classification loss function \(L_{cls}\) can be defined as:  
\[L_{class}(p_{i},p_{i}^{*})=-(1-p_{i}^{*})log(1-p_{i})-p_{i}^{*}\log(p_{i}), \tag{2}\]  
In this study, we adopt the same smooth L1 loss proposed in fast R-CNN [22] as the regression loss function to learn the transformation from each candidate box to its nearest ground-truth box:  
\[L_{reg}(t_{i},t_{i}^{*})=smooth_{L1}(t_{i}-t_{i}^{*}), \tag{3}\]  
\[smooth_{L1}(x)=\left\{\begin{matrix}0.5x^{2},&|x|<1\\ |x|-0.5,&\text{otherwise}\end{matrix}\right., \tag{4}\]  
where \(t_{i}=\left[t_{x},t_{y},t_{w},t_{h}\right]\) represent the four parameter coordinates of the prediction box and \(t_{i}^{*}=\left[t_{x}^{*},t_{y}^{*},t_{w}^{*},t_{h}^{*}\right]\) represent the parameter coordinates corresponding to the ground-truth box. The relationship to the anchor frame is expressed as follows:  
\[t_{x}=\frac{\left(x_{p}-x_{a}\right)}{w_{a}},\;t_{y}=\frac{\left(y_{p}-y_{a} \right)}{h_{a}},\;t_{w}=log\frac{w_{p}}{w_{a}},\;t_{w}=log\frac{h_{p}}{h_{a}},\]  
Figure 2: Detailed framework diagram of pedestrian detection based on pose information and an attention mechanism.  
\[t_{x}^{*}=\frac{(x^{*}-x_{a})}{w_{a}},\ t_{y}^{*}=\frac{(y^{*}-y_{a})}{h_{a}},\ t_{w}^{*}= log\frac{w^{*}}{w_{a}},\ t_{h}^{*}=log\frac{h^{*}}{h_{a}}, \tag{5}\]  
where x and y represent the center point coordinates of the target frame; w and h represent the target frame's width and height, respectively; \(x_{p}\) represents the predicted box; \(x_{a}\) represents the anchor box; and \(\mathbf{x}^{*}\) represents the ground-truth box.  
If all target candidate regions are obtained, duplication and redundancy are eliminated using the non-maximum suppression (NMS) algorithm. Existing detectors (such as ALFNet [29], FCOS [49] (ResNet50), and FCOS [49] (VoVNet39)) were selected as region-generating networks to roughly extract the candidate regions of pedestrian targets. As these detectors generate many false detection and low-confidence areas, the pedestrian recognition network developed to solve this problem is described in detail below.