AI that spots weapons in real time. Just YOLOv8, a camera, and a model trained to protect.
This project harnesses the power of YOLOv8 to detect weapons like guns and knives directly from live webcam feeds or video footage. You can train it on a custom dataset from Kaggle or run it instantly using a pretrained best.pt model. Perfect for smart surveillance, AI-powered security systems, and anyone looking to fuse deep learning with real-world safety.
weapon-detection/
βββ dataset/ # YOLO-formatted dataset (downloaded from Kaggle)
βββ best.pt # Pretrained model (optional)
βββ detect.py # Real-time detection script
βββ train_colab.ipynb # Google Colab training script
βββ README.md
- Python 3.8+
- Ultralytics YOLOv8
- OpenCV
- PyTorch
- Download best.pt from this GitHub repo or from your training.
- Place it in your project directory.
- Update detect.py:
model_path = r"C:/..."
-
Open train_colab.ipynb in Colab.
-
Follow steps to:
- Run training
- Download best.pt after training
from google.colab import files files.download('runs/detect/train/weights/best.pt')
-
Update detect.py:
model_path = r"C:/..."
Run the detect.py:
python detect.pyWhether you're a developer, researcher, or enthusiast β if you're passionate about AI, computer vision, or building for public safety, let's connect!
Feel free to open issues, suggest features, or submit pull requests.
Always open to ideas, improvements, and partnerships.