# Seatbelt Detection Algorithm Improved with Lightweight Approach and Attention Mechanism
## 3 Methodologies
### Seattleblt Classification Based on RST-Net
#### 3.3.2 Triplet Attention  
After the above-mentioned channel pruning approach, the performance of RS-Net and the competence of feature extraction usually suffer due to the variations in construction compared to initial Res-Net. To address this issue, the common method is to introduce a fine-tuning operation, where the parameters of the pruned model are retrained to make up for the supplemental reduction in performance. Although this method can assist in the restoration of the network, it may not fully realize the demand of seatbelt recognition in complicated environments. Hence, a novel and prevalent attention mechanism is introduced to recover and strengthen the capacity of the slight residual network. Triplet attention proposed by [PERSON] et al. (2016) establishes relationships among various domains of feature information through exploiting inter-dimensional feature maps under a marginal computing cost, which is illustrated in Figure 6. Unlike the traditional attention module, triplet attention places emphasis on the significance of encoding cross-dimension information mutually rather than calculating irrespectively. Figure 5: The process of channel pruning approach. Figure 6: Illustration of the triplet attention module. In particular, the input \(\chi\in\mathbb{R}^{C\times H\times W}\) first feeds into three various branches, which separately execute interaction operations of features from diverse dimensions, i.e., (C, H), (C, W), and (W, H), where W, H, and C denote the width, height, and the quantity of channels of the input, respectively. For the (C, H) branch, \(\chi\) is rotated 90\({}^{\circ}\) counterclockwise along the H axis. The rotated tensor denoted as \(X_{1}\) is of the dimension (W, H, C). Subsequently, the Z-pool block is utilized to produce a tensor of shape (2, H, C). The Z-pool operation performs max pooling and average pooling at the first dimensionality and eventually concatenates the values, as shown in Equation (7). \[Z-\text{pool}(\chi)=\left[\text{MaxPool}_{\text{0d}}(\chi),\text{AvgPool}_{ \text{0d}}(\chi)\right] \tag{7}\]  
where 0\(d\) represents the 0 th dimension that performs max pooling and average pooling operations, and [ ] denotes the concatenation conduct. Subsequently, the output of Z-pool is transmitted through a conventional convolution layer with kernel shape \(k\times k\) and a BN layer to obtain a tensor of dimension (1, H, C). The expected weights are generated through delivering the tensor to a sigmoid function and then applied to \(X_{1}\). Ultimately, the acquired tensor is rotated 90\({}^{\circ}\) clockwise along the H axis to preserve the initial dimension of \(\chi\). For the (C, W) and (W, H) branches, the processing operations are akin to a former bypass. The unique distinction is that the (C, W) bypass rotates along the W axis, while a rotation operation does not exist in the (W, H) branch. These operations capture inter-channel and spatial feature maps, allowing the network to exploit interactions between various domains of feature maps effectively. Eventually, the final refined attention map \(y\) can be depicted in Equation (8):  
\[y=\frac{1}{3}(\theta_{1}X_{CH}+\theta_{2}X_{CW}+\theta_{3}X_{WH}) \tag{8}\]  
where \(\theta_{1}\), \(\theta_{2}\), and \(\theta_{3}\) are the three inter-domain attention weights; \(X_{CH}\), \(X_{CW}\), and \(X_{WH}\) denote the tensor generated by the various branches. Figure 7 represents the complete improvement procedure. In this study, Res-Net is first pruned using the channel pruning technique. The channel pruning approach can utilize the scaling coefficients in BN and sort them according to their values, eventually filtering out the insignificant feature channels to lower the number of computational operations and accomplish an inference speedup without compromising precision.