Real-Time Weapon Detection Using Enhanced YOLO12 Models and a Custom Dataset
The paper presents a customized version of the YOLOv12 model that enables better detection of small, occluded, and low-contrast weapons in video sequences while maintaining high precision and real-time inference speed. The new model integrates: 1) loss reweighting strategy that emphasizes small objects’ contributions during training; and 2) set of lightweight, append-only enhancement modules placed in the detection head of the baseline architecture. A large-scale custom dataset has been developed, including more than 26,528 images and 38,167 labeled instances, extracted from about 1,200 YouTube videos and curated web images. The dataset includes three weapon types (knife, pistol, long-gun) and an additional no_weapon class (showing images prone to being easily confused with true instances) to reduce false-positive detections. When benchmarked against the baseline YOLOv12s model, our customized version demonstrated a 4.9% increase in mAP@50, 7.2% in mAP@50-95, 3.8% and 7.1% improvements in Precision and Recall, respectively, while maintaining real-time inference speed.