# Lightweight Violence Detection Model Based on 2D CNN with Bi-Directional Motion Attention
## 3 Proposed Violence Detection Model
### Data Preprocessing  
In the data preprocessing stage, sparse sampling, RGB2 Gray, and frame-grouping operations are performed successively so that the target video clip is put into the format suitable for the following 2D CNN network.  
The purpose of sparse sampling is to reduce redundancy in videos at the frame level. In reality, there is a high degree of redundancy in videos especially in cases of high frame rates. Dense sampling inevitably captures too many highly similar consecutive frames. For violence detection in videos, dense temporal sampling is costly in both time and computing resources. In contrast, sparse sampling preserving relevant information can be used to model the long-range temporal structure over the video with a much lower cost [8; 20]. In this work, we adopt the sparse sampling strategy proposed in [8] to remove redundancy.  
As shown in Figure 1, a video clip of a fixed duration is divided into 3T segments, and one frame is sampled from each segment. Thus, all 3T RGB frames, **F** = [F\({}_{1}\), F\({}_{2}\), \(\ldots\), F\({}_{3T}\)], are captured from the video clip for use in the following procedure.  
Based on the sparsely sampled RGB frames, the RGB2 Gray operation is performed to reduce redundancy further at the channel level. Traditionally, 2D/3D CNNs are employed to learn features from RGB images/frames so as to realize tasks such as image classification and object detection and tracking. However, though color information may be useful for violence detection, motion information has been found to be the most crucial [27; 28; 29; 30; 39]. Moreover, compacting RGB images into single-channel images is beneficial to lowering computational load. Based on this observation, RGB images were squeezed into single-channel ones by using an averaging operation along channel dimension [15]. In this work, we convert the sparsely sampled RGB images into grayscale images using the standard weighted averaging method instead of the method in [15]. Mathematically, the obtained grayscale pixel intensity \(I(x,y)\) can be given by  
\[I(x,y)=W_{\text{R}}I_{\text{R}}(x,y)+W_{\text{G}}I_{\text{G}}(x,y)+W_{\text{B} }I_{\text{B}}(x,y), \tag{1}\]  
where, \(I_{\text{R}}\), \(I_{\text{G}}\), and \(I_{\text{B}}\) represent intensities of the red, green, and blue channels of the pixel, separately; \(W_{\text{R}}=0.30\),\(W_{\text{G}}=0.59\), and \(W_{\text{B}}=0.11\) are standard weighting coefficients obtained from the human luminance perception system. As shown in Figure 1, 3T grayscale frames, **X** = [X\({}_{1}\), X\({}_{2}\),\(\ldots\), \({}_{3T}\)], are obtained from the video clip.  
The function of frame-grouping is to reshape the obtained grayscale frames into three-channel images. According to Figure 1, the obtained 3T grayscale frames are divided into T groups, each of which contains three consecutive frames. For each group, a three-channel image is constructed by putting the three grayscale frames into RGB channels [15]. Therefore, T three-channel images, **I** = [I\({}_{1}\), I\({}_{2}\),\(\ldots\), I\({}_{T}\)], are obtained from a video clip and fed to the following 2D CNN as input. The shape of **I** is [T, C, H, W], where T is a temporal dimension, C denotes the number of channels, and H and W represent the height and width of the image, respectively. As reported in [15], the merit of frame-grouping is twofold. Firstly, the synthesized three-channel images are fit for 2D CNNs in format. Secondly, the synthesized three-channel images enable 2D CNNs to learn short-term motion features. In this work, we take the advantages of frame-grouping and propose a new lightweight 2D CNN, i.e., improved EfficientNet-B0, to extract both short-term and long-term motion features effectively.