Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Handgun Detection using Deep Learning

A computer vision project for detecting handguns in images, videos, and webcam streams using the YOLO object detection framework. The project includes dataset preparation, model training, evaluation, and inference utilities, providing a complete workflow for developing and deploying an object detection model.


Overview

This project implements an end-to-end object detection pipeline for handgun detection using deep learning. It covers data preparation, model training, evaluation, and real-time inference, making it suitable for experimentation with object detection techniques and surveillance-related research.

The repository is organized into modular scripts for dataset preparation, training, and inference, allowing individual components to be reused or extended.


Features

  • Handgun detection in images
  • Video-based object detection
  • Real-time webcam inference
  • Dataset preparation for YOLO training
  • Modular training and inference scripts
  • Support for custom datasets

Model

The project uses the YOLO object detection framework to localize and classify handguns.

The pipeline includes:

  • Dataset preparation
  • Annotation conversion
  • Train-validation split
  • Model training
  • Performance evaluation
  • Image and video inference

Supported input sources include:

  • Images
  • Videos
  • Webcam streams

Project Structure

handgun-detection/
│
├── data/
│   └── Data.md
│
├── notebooks/
│   ├── handgun_detection_train.ipynb
│   └── handgun_detection_inference.ipynb
│
├── prepared_data/
│   ├── images/
│   ├── labels/
│   └── data.yaml
│
├── runs/
│
├── scripts/
│   ├── prepare_data.py
│   ├── run_inference.py
│   ├── split_dataset.py
│   └── train_yolo.py
│
├── utils/
│   └── coco_to_yolo.py
│
├── results_metrics.txt
├── requirements.txt
└── README.md

Installation

Clone the repository:

git clone https://github.com/gopal092003/handgun-detection.git

cd handgun-detection

Install the required dependencies:

pip install -r requirements.txt

Dataset Preparation

Prepare the dataset before training by converting annotations into the YOLO format and creating the train-validation split.

python scripts/prepare_data.py

python scripts/split_dataset.py

Training

Train the YOLO model using:

python scripts/train_yolo.py

Model checkpoints and training results are saved in the runs/ directory.


Inference

Run inference on a video:

python scripts/run_inference.py

The notebooks also demonstrate inference on images and video streams.


Results

The trained model is capable of detecting handguns under a variety of lighting conditions and viewing angles while maintaining near real-time inference performance.

Evaluation metrics are available in:

results_metrics.txt

Technology Stack

  • Python
  • YOLO
  • OpenCV
  • PyTorch
  • NumPy
  • Matplotlib

Future Improvements

  • Expand the training dataset
  • Support multiple weapon categories
  • Improve detection accuracy for challenging scenes
  • Optimize inference for edge devices
  • Deploy as a web application or API

Author

Gopal Gupta

GitHub: https://github.com/gopal092003


License

This project is licensed under the MIT License.

About

Deep learning-based handgun detection system using computer vision to identify weapons in images, videos, and real-time streams for surveillance and security applications.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages