Skip to content

Latest commit

Β 

History

50 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


Python YOLOv8 OpenCV License Status


"Safety isn't expensive, it's priceless."
Automating PPE compliance so every worker goes home safe.



πŸ“Œ Table of Contents


πŸ” Overview

Real-Time PPE Detection System is an end-to-end Computer Vision application that automatically identifies whether workers are wearing required Personal Protective Equipment β€” helmets, safety vests, gloves, and more β€” using state-of-the-art object detection.

Built on YOLOv8 (You Only Look Once v8) and OpenCV, this system delivers fast, accurate inference on both static images and live video streams, making it production-ready for integration into industrial safety pipelines.

⚑ Part of an Applied AI Engineering roadmap focused on building real-world, deployable AI systems.


🌍 The Real-World Problem

Every year, thousands of workplace injuries occur due to missing or improper use of Personal Protective Equipment. In environments like:

Environment Common PPE Required
πŸ—οΈ Construction Sites Helmets, safety vests, boots
🏭 Factories & Warehouses Gloves, goggles, hard hats
βš—οΈ Chemical Plants Full-body suits, face shields
πŸ”Œ Electrical Facilities Insulated gloves, arc flash gear

Manual monitoring of PPE compliance across large facilities is:

  • ❌ Time-consuming and error-prone
  • ❌ Impossible to scale with limited supervisors
  • ❌ Reactive rather than preventive
  • ❌ Subject to human fatigue and oversight

This system makes compliance monitoring proactive, automated, and scalable β€” detecting violations in real time before accidents happen.


βš™οΈ How It Works

The system is built on a simple, modular inference pipeline β€” any input source (image, video file, or live webcam stream) is passed through YOLOv8 for detection, then annotated with bounding boxes and confidence scores before being written to an output file or displayed on screen.

Each component is decoupled, making it easy to swap in a custom-trained PPE model, add a new input source, or plug in an alerting layer without touching the rest of the pipeline.

See the Detection Workflow section for the full pipeline diagram.


🧠 Tech Stack

Technology Role Version
Python Core language 3.8+
YOLOv8 (Ultralytics) Object detection model Latest
OpenCV Image/video processing 4.x
PyTorch Deep learning backend 2.x
NumPy Numerical operations 1.24+

πŸ“‚ Project Structure

real-time-ppe-detection-system/
β”‚
β”œβ”€β”€ app/
β”‚   └── inference.py          # πŸ” Core detection script
β”‚
β”œβ”€β”€ data/                     # πŸ“ Input images & videos
β”‚   β”œβ”€β”€ images/
β”‚   └── videos/
β”‚
β”œβ”€β”€ models/                   # πŸ€– YOLOv8 model weights (.pt files)
β”‚   └── yolov8n.pt
β”‚
β”œβ”€β”€ outputs/                  # πŸ“€ Annotated detection results
β”‚   β”œβ”€β”€ images/
β”‚   └── videos/
β”‚
β”œβ”€β”€ requirements.txt          # πŸ“¦ Python dependencies
└── README.md                 # πŸ“– Project documentation

πŸš€ Getting Started

Prerequisites

  • Python 3.8 or higher
  • pip package manager
  • Git

1. Clone the Repository

git clone https://github.com/gee-46/real-time-ppe-detection-system.git
cd real-time-ppe-detection-system

2. Set Up a Virtual Environment

Create the environment:

python -m venv venv

Activate β€” Windows:

venv\Scripts\activate

Activate β€” macOS / Linux:

source venv/bin/activate

3. Install Dependencies

pip install ultralytics opencv-python numpy

Or using requirements.txt (recommended):

pip install -r requirements.txt

requirements.txt:

ultralytics>=8.0.0
opencv-python>=4.8.0
numpy>=1.24.0

4. Run Inference

python app/inference.py

πŸ“Œ By default, the script runs detection on images inside the data/ directory.
Modify inference.py to point to your own images, video files, or webcam feed.


🧩 Detection Workflow

The detection pipeline follows a clean, modular flow from any input source to annotated output:

πŸ“· Input Source (Image / Video / Webcam)
          β”‚
          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frame Capture     β”‚  ← OpenCV VideoCapture / imread
β”‚   & Preprocessing   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   YOLOv8 Inference  β”‚  ← Ultralytics model.predict()
β”‚   (Object Detection)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Post-Processing    β”‚  ← Bounding boxes, class labels,
β”‚  & Visualization    β”‚     confidence scores overlay
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β–Ό
πŸ“€ Output (Annotated Image / Video / Alert)

✨ Features

Feature Status
🎯 YOLOv8 object detection βœ… Available
πŸ–ΌοΈ Image-based detection βœ… Available
πŸ“¦ Bounding box visualization βœ… Available
🏷️ Class label + confidence overlay βœ… Available
πŸŽ₯ Video file inference βœ… Available
πŸ“Ή Live webcam detection πŸ”œ Coming Soon
🦺 PPE-specific custom model πŸ”œ Coming Soon
🚨 Real-time alert system πŸ”œ Coming Soon
🌐 FastAPI backend πŸ”œ Coming Soon

πŸ—ΊοΈ Roadmap

Phase 1 β€” Foundation (Current)         βœ…
β”œβ”€β”€ YOLOv8 integration
β”œβ”€β”€ Image-based detection pipeline
└── Bounding box + label visualization

Phase 2 β€” Live Detection               πŸ”œ
β”œβ”€β”€ Webcam / RTSP stream support
β”œβ”€β”€ Multi-frame processing
└── Real-time FPS optimization

Phase 3 β€” PPE-Specific Model           πŸ”œ
β”œβ”€β”€ Custom dataset (helmets, vests, gloves)
β”œβ”€β”€ Fine-tune YOLOv8 on PPE classes
└── Confidence threshold tuning

Phase 4 β€” Alerts & Backend            πŸ”œ
β”œβ”€β”€ Violation alert system (sound/email)
β”œβ”€β”€ FastAPI REST API integration
└── Detection logs & reporting

Phase 5 β€” Deployment                  πŸ”œ
β”œβ”€β”€ Docker containerization
β”œβ”€β”€ Edge deployment (Raspberry Pi / Jetson)
└── Cloud API (AWS / GCP)

πŸŽ“ Learning Outcomes

This project covers the following concepts hands-on:

  • βœ… Computer Vision Fundamentals β€” image processing, frame handling, color spaces
  • βœ… Object Detection β€” understanding YOLO architecture, bounding boxes, IoU, NMS
  • βœ… Real-Time Inference β€” optimizing detection pipelines for speed
  • βœ… OpenCV Workflows β€” reading images/videos, drawing annotations, displaying results
  • βœ… Deep Learning Integration β€” using pretrained models from Ultralytics
  • βœ… AI for Safety Systems β€” applying AI to solve real industrial problems

πŸ‘€ Author


Built by gee-46

Part of an Applied AI Engineering roadmap β€” building production-ready AI systems for real-world deployment.


GitHub


If this project helped you, consider giving it a ⭐ on GitHub!



πŸ“„ License

This project is licensed under the MIT License β€” free to use, modify, and distribute.


About

AI-powered workplace safety monitoring system using YOLOv8 and OpenCV for real-time PPE detection.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages