Giter Site home page Giter Site logo

dhvani-k / firearm_detection_in_cctvs_using_yolov5 Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 21.57 MB

Detects firearms in real-time from CCTV videos, highlighting them within bounding boxes for immediate attention

License: MIT License

Jupyter Notebook 99.04% Python 0.96% Shell 0.01%
cctv-cameras cctv-detection cctv-monitoring darknet deep-learning firearm-detection firearms guns machine-learning neural-networks

firearm_detection_in_cctvs_using_yolov5's Introduction

Real-Time Firearm Detection from CCTV Footage

Introduction

In the interest of public safety, early detection of potentially violent situations is paramount. One proactive approach is to identify the presence of firearms in surveillance footage. This project aims to detect firearms in real-time from CCTV videos, highlighting them within bounding boxes for immediate attention.

Problem Statement

The goal is to develop a model that can process CCTV footage and identify firearms frame-by-frame, marking their presence with a bounding box. This early warning system can be instrumental in preventing potential threats and ensuring public safety.

Dataset

We utilize the "Guns Object Detection" dataset available on Kaggle. This dataset comprises:

  • Labeled images of firearms sourced from various online platforms.
  • Square reconstructed images retained in RGB/BGR format.
  • The Images folder containing jpeg photographs.
  • The Labels folder with corresponding text files detailing object coordinates.

Each text file starts with a list of objects from its corresponding image and concludes with the object's coordinates. This dataset serves as the foundation for our training.

Algorithm

The YOLOv3 (You Only Look Once version 3) algorithm is our choice for firearm detection. Key highlights of our approach include:

  • Training on a dataset with a singular class: firearms.
  • Real-time identification of weapon types from CCTV footage post-training.
  • Immediate threat alerts to relevant authorities upon weapon detection.
  • YOLOv3's unique architecture that combines feature extraction and object localization into a unified block, ensuring rapid inference.
  • Unlike traditional methods that scan images with a sliding window, YOLO processes the entire image through a Convolutional Neural Network (CNN) in a single pass, predicting bounding box coordinates and class probabilities simultaneously.
  • Our dataset, housed in the darknet folder, is uploaded to a drive, segmented into 70% training and 30% testing data, and organized for continuous model training.
  • We leverage OpenCV's deep neural network module, which incorporates Darknet's deep learning framework (where YOLO originates). Our code loads the network, processes the YOLOv3 configuration and weights, and reads an input image. Post neural network processing, predictions are refined by removing low-confidence detections and applying non-max suppression to eliminate redundant bounding boxes, ensuring optimal object detection. Weapon detection triggers an alert.

Execution

Follow these steps to execute the firearm detection:

Requirements:

  • Python 3.8 or newer.
  • Ensure all dependencies are installed using:

$ pip3 install -r requirements.txt

  • Avoid altering configuration or weight files; they result from training YOLO v3 on the Kaggle gun dataset.

Steps:

  1. The training code is available in the Training_YoloV3_firearm_detection.ipynb Jupyter notebook. Execute this notebook on Google Colab to generate the necessary configurations and weights.
  2. main.py facilitates firearm detection in three scenarios:
    • Image
    • Video
    • Real-time
  3. For code execution, run the run.sh file. By default, main.py uses inputs from the root directory for gun detection.

References:

  1. Introduction to YOLO Algorithm for Object Detection
  2. Object Detection with YOLOv3 in Keras
  3. YOLO Object Detection with OpenCV

firearm_detection_in_cctvs_using_yolov5's People

Contributors

dhvani-k avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

piyachon1234

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.