Lightweight YOLOv8 Optimized Deep Neural Network for Real-Time Weapon Detection on Raspberry Pi 5 in Smart Surveillance Systems

Amah Gideon Gbaden *

Department of Computer Engineering Technology, Federal Polytechni Wannune, Benue State, Nigeria.

Jonathan A. Enokela

Department of Electrical and Electronics Engineering, Joseph Sarwuan Tarka University Makurdi (JOSTUM), Makurdi, Benue State, Nigeria.

David O. Agbo

Department of Electrical and Electronics Engineering, Joseph Sarwuan Tarka University Makurdi (JOSTUM), Makurdi, Benue State, Nigeria.

Tersoo E. Iorkyase

Department of Electrical and Electronics Engineering, Joseph Sarwuan Tarka University Makurdi (JOSTUM), Makurdi, Benue State, Nigeria.

*Author to whom correspondence should be addressed.


Abstract

Background: The increasing prevalence for public safety threats necessitates the development of intelligent surveillance systems that are capable of real-time weapon detection. These conventional deep learning models achieve high accuracy but are mostly computationally intensive, limiting their deployment on edge devices. The deep learning models have proven to be great, particularly the, you only look once version (YOLOv8) algorithm when applied on Raspberry Pi 5 and web camera.

Aims: This research proposes a lightweight and optimized YOLOv8-based deep neural network, specifically tailored for deployment on the Raspberry Pi 5.

Study Design: The model is designed using raspberry pi, USB web camera with Google colab baseline.

Place and Duration of Study: Sample: Department of Electrical and Electronics Engineering, Joseph Sarwuan Tarka University Makurdi, Nigeria and Department of Computer Engineering Technology, Federal Polytechnic Wannune Nigeria, between June 2024 and January 2025.

Methodology: The study used a dataset comprising custom images of six (6) classes and corresponding annotations and labeling specifically tailored for weapon detection. The datasets were captured using USB web camera on raspberry pi 5 using some algorithms of the API and terminal of the raspberry pi5 to have the web camera capture the images in a saved folder. The images were pre-processed and augmented as necessary using algorithms to launch labelimg on raspberry pi 5 platforms to annotate and label the images. Because of the memory and the available TPU on google colab, a google drive was created to upload the datasets and had the model trained using the google colab. The datasets were split on a ratio of 70%, 20% and 10% on train, validate and test respectively with a yaml file of train and val on a class of six (6). It was then proceeded to train the YOLOv8 model, a state-of-the-art object detection architecture, on this dataset.  The model was trained, validated and tested using standard evaluation metrics such as precision, recall, and mean Average Precision (MAP). Next, the model (best.pt) was deployed on raspberry pi 5 using an algorithm developed as a user-friendly interface to test the images on the model with the aid of the USB web camera.

Results: The dataset after annotation and label was uploaded to google drive and google colab was used for the training of the model after downloading and installing ultralytics and all the dependencies. A yaml file was created with the train and val datasets with their respective paths. The study also shows the result samples of train/box, losses metrics: recall, precision, validation/box, losses and metrices/mAP at _0.5 and metricsmAP_05:0,95 with result showing experimental validation demonstrates that the optimized YOLOv8 model achieves real-time inference at over (axe = 97 %, daga = 97 %, handgun = 93 %, knife = 97 %, matchet = 99 % and picer = 99 %) with a mean average precision (mAP) of 96 % accuracy.

Conclusion: The implementation of YOLOv8 for weapon detection on the Raspberry Pi 5 represents a significant advancement in both deep learning algorithms and edge device capabilities. YOLOv8’s improvement over previous versions and the enhanced computational power of the Raspberry Pi 5 provides a robust platform for real-time weapon detection. Future research should continue to address the challenges of deploying advanced models on edge devices and explore innovative solutions to enhance detection accuracy and efficiency.

Keywords: Weapon detection, YOLO, surveillance, camera, raspberry Pi, vision, smart


How to Cite

Gbaden, Amah Gideon, Jonathan A. Enokela, David O. Agbo, and Tersoo E. Iorkyase. 2025. “Lightweight YOLOv8 Optimized Deep Neural Network for Real-Time Weapon Detection on Raspberry Pi 5 in Smart Surveillance Systems”. Journal of Engineering Research and Reports 27 (11):99-112. https://doi.org/10.9734/jerr/2025/v27i111688.

Downloads

Download data is not yet available.