Paper Contents
Abstract
Public safety in high-risk environments such as airports, schools, malls, and public gatherings requires rapid and reliable identification of potential threats. This study presents a Python-based Weapon Detection System designed to automatically detect and classify weapons in images and video streams in real time. The system leverages advanced deep learning models, primarily based on transfer learning techniques, incorporating architectures such as YOLOv8, Faster R-CNN, and SSD for high accuracy in object localization and classification. A curated dataset, sourced from publicly available repositories and custom-labeled CCTV footage, is used to train the models on multiple weapon categories including pistols, rifles, knives, and blunt objects.The preprocessing pipeline integrates noise reduction, brightness normalization, and motion-based frame selection to enhance detection under challenging conditions such as poor lighting, occlusion, and crowded backgrounds. Data augmentation techniquesrotation, flipping, Gaussian noise, and synthetic low-light generationare applied to improve model robustness. Post-processing involves confidence thresholding, non-maximum suppression, and temporal consistency filtering to minimize false positives and improve stability in continuous video streams.The Python implementation utilizes OpenCV for video handling, PyTorchTensorFlow for model training and inference, and FlaskFastAPI for serving REST APIs. The trained model is converted into ONNX format for deployment on resource-constrained devices, enabling edge computing with minimal latency. Performance evaluation on a separate validation dataset shows mean Average Precision (mAP@0.5) above 85%, precision above 90%, and recall exceeding 88%, achieving real-time inference speeds of over 30 FPS on mid-range GPUs.Security and ethical considerations are integrated into the system design, including privacy-preserving measures such as facial blurring and on-premises deployment to avoid transmitting sensitive footage to cloud servers. This research demonstrates that Python-based AI weapon detection systems can significantly improve the speed and reliability of threat identification, allowing for faster response times and potentially saving lives in critical situations.
Copyright
Copyright © 2025 Sahana S D. This is an open access article distributed under the Creative Commons Attribution License.