# Development and Optimization of Deep Learning Models for Weapon Detection in Surveillance Videos
## 5 Conclusions  
Automatic weapon detection systems need to be installed in public places to prevent criminal activities before they occur. It is a challenging task to develop an accurate and efficient system with minimum false alarms. We have used a deep learning-based approach to CCTV videos to develop a highly accurate weapon detection model to achieve inference in real time. We implemented the Scaled-YOLOv4 algorithm to achieve high accuracy, as well as improved FPS compared to existing methods. Moreover, we investigated the model deployment on embedded edge computing devices to achieve lower latency, higher throughput, and improved privacy. The comparison is performed between our Scaled-YOLOv4-based weapon detector and the previously developed weapon detectors, in terms  
Figure 19: Misdetection results of Scaled-YOLOv4 in real-time CCTV stream.  
Figure 18: Detection results of Scaled-YOLOv4 in real-time CCTV stream. **(a)** Image with a rifle as weapon held diagonally. **(b)** Image with a rifle as a weapon held upside down slightly tilted.  
of accuracy and inference time on different machines. The results indicate that our weapon detection model is superior to the existing approaches in all aspects and generalizes well in detecting all weapon categories. We have also presented the results by changing different hyperparameters of the model and observed their effect on the overall performance of the model. In addition, we provided insights on TensorRT network optimization that has enabled deployment on the popular edge computing device, i.e., Jetson Nano. The network optimization resulted in only a slight reduction in the mAP score (causing the occurrence of higher false positives) and 4.26 FPS, which is a reasonable score for resource-constrained Jetson Nano device. Finally, it is concluded that the presented models give very good performance in terms of accuracy and inference time if implemented on a high-performance GPU (such as RTX 2080 TI). On the other hand, acceptable performance can be achieved if the optimized model is implemented on the edge using low-cost Jetson Nano for weapon detection in live CCTV surveillance videos. Nevertheless, further improvement and optimization are required for better accuracy and higher FPS. In the future, we suggest that researchers should use pose estimation techniques in conjunction with object detection to further enhance the mAP score of the weapon detection surveillance system.  
Conceptualization, S.A. and M.G.K.; methodology, S.A. and M.T.B.; software, S.A.; validation, S.A., M.T.B. and M.G.K.; resources, M.G.K. and B.L.; data curation, M.T.B.; writing--original draft preparation, S.A. and M.T.B.; writing--review and editing, M.G.K., B.L. and M.S.; visualization, S.A.; supervision, M.G.K. and M.S.; project administration, M.G.K.; funding acquisition, M.G.K. and B.L. All authors have read and agreed to the published version of the manuscript. This research received no external funding.  
Not applicable.  
Dataset for real-time detection was collected and constructed in different phases and data were collected from the internet, extracted from YouTube CCTV videos, through GitHub repositories, data by the University of Granada research group, and internet movie rear database imfdb.org. This data will be available upon request.  
The authors declare no conflict of interest.