# Lightweight Violence Detection Model Based on 2D CNN with Bi-Directional Motion Attention
Three-dimensional CNNs can extract both spatial and temporal features in videos effectively and thus lead to high performance in tasks of behavior recognition. In comparison with 2D convolution kernels, 3D convolution kernels are capable of extracting motion features lying in the temporal dimension of videos. The C3D [4], R3D [5], and I3D [6] are typical 3D CNNs proposed for action recognition tasks and exhibit significant improvement in recognition accuracy. It is worth noting that 3D CNN models are computationally expensive for real-world applications. Two-stream networks combining RGB frames and optical flow have also been proposed for video detection [7; 8; 9; 10; 11; 12]. The idea is to make use of the spatial information lying in RGB frames and the motion information lying in optical flow. The spatial features extracted by CNNs from RGB images and the optical flow are fused to realize video detection tasks. Though good performance can be achieved by using these schemes, the complicated calculation of optical flow turns out to be an obstructive factor for real-world applications. Skeleton-based action recognition schemes rely on precise estimates of the sequence of skeleton points [13; 14]. The sequence of skeleton points is firstly extracted from the video and then transformed to match the input format of the following CNN model [13] or graph convolutional network (GCN) model [14]. Evidently, it is computationally demanding to extract skeleton points from videos, and extra errors in skeleton points may lead to misjuddment of actions. Regarding the design of automatic violence detection systems, most researchers focus on the architecture of the Internet of Things (IoT). For real-time applications, the latencies required are usually on the scale of sub-second [15; 16], and therefore it is more promising to implement violence detection on cameras or edge devices than on clouds. The authors of [15] embedded their algorithm on a camera module to realize on-camera violence crime detection. NVIDIA RTX 3090 and Jetson TX2 were employed to test the latencies of their models. The authors of [16] focused on violence detection on edge devices, each of which serves multiple surveillance cameras. NVIDIA RTX 3070 TI and NVIDIA Jetson Xavier NX were employed to test the inference speed of their model. The author of [17] proposed an edge vision-based surveillance system for violence detection in public and private spaces. For inference tasks, Jetson AGX Orin 64 GB was employed in their edge devices. Due to the fact that surveillance cameras and edge devices are usually resource-limited platforms, a violence detection model with low memory complexity and low computational cost is desirable. In this paper, we focus on edge device-based violence detection as in [16; 17]. It is expected that an edge device with limited resources, e.g., a desktop computer with a GPU card, can detect violence reliably from videos acquired by a number of surveillance cameras. Specifically, we propose a lightweight 2D CNN-based violence detection scheme. The key idea is to extract both short-term and long-term motion features effectively from videos using an improved EfficientNet-B0 [18], a lightweight 2D CNN. As shown in Figure 1, the pipeline of the proposed scheme consists of three stages: data preprocessing, 2D CNN-based feature extraction, and classification. In the data preprocessing stage, sparse sampling [8] and RGB2 Gray operation are performed to reduce data redundancy, and then frame-grouping [15] is conducted to assemble three-channel images fit for the following 2D CNN. In the following feature extraction stage, an improved EfficientNet-B0 is employed to extract short-term and long-term motion features. In the classification stage, cross-entropy loss (the main loss) is applied together with an auxiliary loss [19] to supervise the training process of the model so as to improve the violence detection accuracy effectively.