Abstract
Automatic detection of weapons in images and video streams is crucial for enhancing surveillance, access control, and public safety. Existing deep learning-based object detectors, such as YOLO11 and Faster R-CNN with feature pyramid networks (FPN), achieve strong performance on generic benchmarks but their effectiveness for firearm and knife detection is constrained by the scarcity of domain-specific annotated data. In this work, we address this limitation through dataset adaptation, defined as selecting, from a larger image collection, only instances belonging to four weapon-related classes and re-annotating them in a unified COCO format with consistent category identifiers and bounding-box metadata. On top of this adapted dataset, we benchmark three state-of-the-art detectors implemented in Python 3.14.3 with PyTorch 2.11.2: YOLO11, Faster R-CNN with a ResNet-50-FPN v2 backbone, and Faster R-CNN with a MobileNetV3-Large-320-FPN backbone, where the background is modeled implicitly by an additional class. All models are trained and evaluated on-premise using two NVIDIA RTX 2080 Ti GPUs under a common experimental protocol. We compare their bounding-box localization performance on firearms and knives, and discuss how dataset adaptation and architectural choices jointly impact accuracy and computational efficiency in this safety-critical application domain.
1. Introduction
Automatic detection of weapons in images and video streams is a critical capability for modern surveillance, access control, and public safety systems. While recent deep learning-based object detectors such as YOLO11 [1] and improved Faster R-CNN [2] variants have demonstrated strong performance on generic benchmarks, their effectiveness on security-oriented tasks like firearm and knife detection still depends heavily on the availability of appropriately annotated data and the choice of detection architecture, such as Faster R-CNN with a ResNet-50-FPN v2 backbone implemented within the Python [3] and PyTorch [4] ecosystem. In particular, bounding-box-based detectors must be trained on datasets that accurately capture the appearance, scale, and context of weapons in realistic environments. However, publicly available datasets targeting weapon detection are limited in size, coverage, or annotation quality, which complicates the training of robust models and the fair comparison of different architectures. In this work, we use the term dataset adaptation to denote the process of selecting, from a larger collection of images, only those instances belonging to a predefined set of weapon-related classes, and re-annotating them in a unified COCO format with consistent category identifiers and metadata. Concretely, we construct a COCO-style dataset centered on four foreground classes, where each annotation includes the bounding-box coordinates, object area, class identifier, and the name of the corresponding image, while the background is handled implicitly by the detection models through an additional background class.
Building on this adapted dataset, we benchmark three state-of-the-art detectors implemented in Python using the PyTorch framework: YOLO11, Faster R-CNN with a ResNet-50-FPN v2 backbone, and Faster R-CNN with a MobileNetV3-Large-320-FPN backbone [5].
All experiments are trained and evaluated on-premise using a workstation equipped with two NVIDIA RTX 2080 Ti GPUs, which enables us to explore different training configurations while keeping the computational setup fixed across models. We report and compare their performance on firearm and knife detection, highlighting the impact of dataset adaptation, model design, and computational budget on bounding-box localization quality in this safety-critical application domain.
2. Materials and Methods
2.1. Dataset
We build our weapon-detection benchmark on a subset of the Open Images dataset [6], a large-scale collection of images with bounding-box annotations over hundreds of object categories. Using the official label hierarchy, we start from the Weapon node and retain only the four classes most relevant for our target scenario: handgun, rifle, shotgun, and knife. All images containing at least one instance of these categories are selected, yielding a weapon-centric subset that still benefits from the visual diversity and context of Open Images.
To integrate this data into standard detection pipelines, we convert the original annotations to the COCO format. Each object instance is stored with its image_id, category_id, axis-aligned bounding box, area, and iscrowd flag, while the categories section enumerates the four weapon classes with integer identifiers from 1 to 4. During training, the PyTorch detectors implicitly treat all remaining pixels as background, so the effective label space comprises these four weapon categories plus a background class, which is not explicitly represented in the annotation file.
2.2. Training Setup
All detectors are implemented in Python using the PyTorch framework and trained on the adapted COCO-style weapon subset described above. We consider three standard optimizers, stochastic gradient descent (SGD) [7], Adam [8], and AdamW [9], combined with either a linear warmup schedule or a cosine-annealing learning rate schedule [10]. For the cosine configuration, the learning rate increases linearly from (almost) zero to a maximum value of during the first 10% of the training steps and then decays according to the cosine policy over the remaining steps. To prevent overfitting and reduce unnecessary computation, we apply early stopping when the target metric does not improve by more than over three consecutive epochs, and we run all experiments on-premise using two NVIDIA RTX 2080 Ti GPUs. Figure 1 illustrates a representative learning-rate schedule under this warmup and cosine-annealing policy.
Figure 1.
Learning-rate schedule for a representative training run with stochastic gradient descent (SGD). The learning rate increases linearly from (almost) zero to a maximum value of during the first 10% of the training steps and then follows a cosine-annealing decay for the remaining 90%, over a total of 50 epochs without early stopping.
2.3. Detection Architectures
In addition to the one-stage YOLO11 baseline, we evaluate two Faster R-CNN detectors with ResNet-50-FPN v2 and MobileNetV3-Large-320-FPN backbones. YOLO11 is a modern single-stage detector that predicts bounding boxes and class scores in a single forward pass, trading some architectural complexity for high throughput and real-time performance. Faster R-CNN, in contrast, follows a two-stage design: a shared convolutional backbone first produces a feature map, a Region Proposal Network (RPN) generates candidate regions, and a final detection head performs classification and bounding-box regression on each proposal.
The ResNet-50-FPN v2 variant adopts the improved training recipe introduced in recent work on transfer learning for detection, updating both the backbone and the feature pyramid network to obtain stronger accuracy while keeping the overall architecture compatible with standard Faster R-CNN implementations. The MobileNetV3-Large-320-FPN backbone provides a lighter alternative with depthwise separable convolutions, which substantially reduces the number of parameters and computations at inference time at the cost of some detection performance.
3. Results
In this section, we focus on the best-performing configuration, namely Faster R-CNN with a ResNet-50-FPN v2 backbone trained using SGD and a cosine-annealing learning-rate schedule. Figure 2 shows the evolution of the total training loss as a function of the optimization steps (epochs multiplied by the number of mini-batches). The loss drops quickly at the beginning of training and then keeps decreasing more slowly until it stabilizes, and the remaining small ups and downs are mostly caused by the randomness of the mini-batches.
Figure 2.
Total training loss for the best-performing model (Faster R-CNN with ResNet-50-FPN v2, SGD, cosine-annealing schedule) as a function of the training steps. A sharp initial decrease is followed by a gradual convergence towards a stable plateau, with small oscillations due to mini-batch stochasticity.
To better understand the behavior of the detector, Figure 3 decomposes the total loss into its main components: bounding-box regression loss for the final head, classification loss, objectness loss, and RPN bounding-box regression loss. All components decrease steadily over time: they drop quickly at the beginning and then decline more gradually until they stabilize, with the classification and final bounding-box terms dominating the magnitude of the total loss, while the RPN regression and objectness terms converge more quickly to small values. The remaining small fluctuations in these curves are mainly due to the randomness of the mini-batches during training.
Figure 3.
Decomposition of the total loss into its main components for the same training run: final bounding-box regression loss, classification loss, objectness loss, and RPN bounding-box regression loss. All components decrease over time, and the proposal-related losses (objectness and RPN box regression) quickly converge to low values, indicating stable region proposals throughout training.
4. Discussion
The proposed dataset adaptation, in which we derive a COCO-style subset of Open Images restricted to handgun, rifle, shotgun, and knife, proved effective for benchmarking weapon detectors under a controlled label space while still preserving the visual diversity of the original corpus. On this adapted dataset, the larger architectures (YOLO11 and Faster R-CNN with a ResNet-50-FPN v2 backbone) consistently achieved the best detection performance, confirming that higher-capacity models benefit from the rich contextual information present in Open Images. In contrast, the Faster R-CNN variant with a MobileNetV3-Large-320-FPN backbone exhibited lower accuracy but remained significantly lighter at inference time, making it an appealing option for deployment on resource-constrained hardware, where latency and memory footprint are critical.
From an optimization standpoint, the configurations described in Section 2.2 had a measurable but secondary impact compared to the choice of architecture and the adapted dataset design. In our experiments, AdamW tended to provide fast and stable convergence, while the combination of learning-rate scheduling and early stopping mainly affected training time rather than altering the relative ranking of the detectors. This suggests that, within a reasonable range of hyperparameters, architectural capacity and dataset curation dominate the final performance for weapon detection on our adapted Open Images subset.
Author Contributions
Conceptualization, M.A.C.-R., G.S.-P., J.P.-P., L.K.T.-M., A.H.-S., J.O.-M., H.M.P.-M. and L.V.-J.; methodology, M.A.C.-R., G.S.-P., J.P.-P. and L.V.-J.; software, M.A.C.-R. and L.V.-J.; validation, M.A.C.-R., G.S.-P., J.P.-P., L.K.T.-M., A.H.-S., J.O.-M., H.M.P.-M. and L.V.-J.; formal analysis, M.A.C.-R., J.P.-P., L.K.T.-M. and L.V.-J.; investigation, M.A.C.-R., G.S.-P. and L.V.-J.; resources, J.O.-M. and H.M.P.-M.; data curation, M.A.C.-R. and L.V.-J.; writing—original draft preparation, M.A.C.-R.; writing—review and editing, M.A.C.-R., G.S.-P., J.P.-P., L.K.T.-M., A.H.-S., J.O.-M., H.M.P.-M. and L.V.-J.; visualization, M.A.C.-R. and L.V.-J.; supervision, A.H.-S., J.O.-M. and H.M.P.-M.; project administration, L.K.T.-M. and A.H.-S. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
The data supporting the reported results are available upon request from the corresponding author. The data are not publicly available due to privacy restrictions.
Acknowledgments
The authors would like to thank the organizers of the First Summer School on Artificial Intelligence in Cybersecurity for providing the academic framework that inspired this research. During the preparation of this manuscript, the authors used Gemini 3.1 Pro (Google) for the purposes of language editing, LaTeX formatting, and assisting with data visualization scripts. The authors have reviewed and edited the output and take full responsibility for the content of this publication.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Ultralytics. YOLOv11 [Computer Software]. 2024. Available online: https://github.com/ultralytics/ultralytics (accessed on 11 March 2026).
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards real-time object detection with region proposal networks. In Proceedings of the 28th International Conference on Neural Information Processing Systems (NeurIPS), Montreal, QC, Canada, 7–12 December 2015; pp. 91–99. [Google Scholar]
- Van Rossum, G.; Drake, F.L. Python 3 Reference Manual; CreateSpace: Scotts Valley, CA, USA, 2009. [Google Scholar]
- Paszke, A.; Gross, S.; Massa, F.; Lerer, A.; Bradbury, J.; Chanan, G.; Killeen, T.; Lin, Z.; Gimelshein, N.; Antiga, L.; et al. PyTorch: An imperative style, high-performance deep learning library. In Proceedings of the Advances in Neural Information Processing Systems 32 (NeurIPS 2019), Vancouver, BC, Canada, 8–14 December 2019; pp. 8024–8035. [Google Scholar]
- Howard, A.; Sandler, M.; Chu, G.; Chen, L.C.; Chen, B.; Tan, M.; Wang, W.; Zhu, Y.; Pang, R.; Vasudevan, V.; et al. Searching for MobileNetV3. In Proceedings of the IEEE/CVF International Conference on Computer Vision, Seoul, Republic of Korea, 27 October–2 November 2019; pp. 1314–1324. [Google Scholar] [CrossRef] [Scilit]
- Benenson, R.; Popov, S.; Bregier, R.; Ferrari, V. Large-Scale Detection in the Open Images Dataset. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Seattle, WA, USA, 13–19 June 2020; pp. 2001–2011. [Google Scholar]
- Robbins, H.; Monro, S. A stochastic approximation method. Ann. Math. Stat. 1951, 22, 400–407. [Google Scholar] [CrossRef] [Scilit]
- Kingma, D.P.; Ba, J. Adam: A method for stochastic optimization. In Proceedings of the 3rd International Conference on Learning Representations (ICLR), San Diego, CA, USA, 7–9 May 2015; pp. 1–15. [Google Scholar]
- Loshchilov, I.; Hutter, F. Decoupled weight decay regularization. In Proceedings of the International Conference on Learning Representations (ICLR), New Orleans, LA, USA, 6–9 May 2019; pp. 1–18. [Google Scholar]
- Loshchilov, I.; Hutter, F. SGDR: Stochastic gradient descent with warm restarts. In Proceedings of the 5th International Conference on Learning Representations (ICLR), Toulon, France, 24–26 April 2017; pp. 1–16. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.


