YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Weapon Detection Using YOLO

This project implements a weapon detection system using YOLO (You Only Look Once) for object detection. It processes a video, detects weapons in each frame, and saves the annotated video.


Features

  • Real-time weapon detection in videos
  • Bounding box annotations on detected weapons
  • Saves the output video with detections
  • Easy-to-use Python implementation

Requirements

Make sure you have the following dependencies installed before running the project:

pip install ultralytics opencv-python

πŸ›  Installation & Setup

Clone the Repository

To get started, clone the repository to your local machine using the following command:

git clone https://github.com/your-username/weapon-detection-yolo.git
cd weapon-detection-yolo

Ensure You Have the Model File

Download best.pt (your trained YOLO model) and place it in the project directory.

Install Dependencies

Make sure you have the required dependencies installed:

pip install ultralytics opencv-python

Run the Detection Script

Execute the following command to run the detection script:

python weapon_detection.py
  • Ensure video.mp4 exists in the directory or update the script to match the correct file path.
  • The output will be saved as weapon_detection_output.mp4.

Exit the Program

  • The program will display video frames with detected weapons.
  • To stop execution, press 'q' on your keyboard.

πŸ“œ Code Overview

  • Load the YOLO model to detect weapons.
  • Process the input video, frame by frame.
  • Apply object detection using the trained model.
  • Save and display results in a new video file with detections.
  • Exit when 'q' is pressed.

πŸ“‚ File Structure

weapon-detection-yolo/
β”œβ”€β”€ best.pt                   # YOLO model file
β”œβ”€β”€ video.mp4                 # Input video
β”œβ”€β”€ weapon_detection.py       # Main script
β”œβ”€β”€ README.md                 # Project documentation
└── weapon_detection_output.mp4  # Output video (after detection)

πŸ–₯ Example Output

https://github.com/user-attachments/assets/28a04e37-afad-45b2-8291-423bcf17fc6d

πŸ“’ Notes

  • If you need to train your own model, refer to the official Ultralytics YOLO documentation.
  • For real-time detection, you can modify the code to process a webcam feed.

  • Go to your repository link and check if all files are uploaded.

🎯 Happy Coding! πŸš€

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support