Local YOLO PPE Detection System - Privacy-First Computer Vision
A comprehensive Personal Protective Equipment (PPE) detection system built with Streamlit and a locally trained YOLO model. Features real-time webcam monitoring, video processing, and image analysis with complete privacy protection through offline processing.
- πΌοΈ Image Analysis - Upload and analyze images for PPE compliance with detailed metrics
- π₯ Video Processing - Process video files with frame-by-frame detection and tracking
- πΉ Live Detection - Real-time webcam monitoring with continuous compliance tracking
- π€ Local Trained Model - Custom-trained YOLO model specifically for PPE detection
- β‘ High Performance - Optimized inference with dedicated virtual environment
- π Privacy First - 100% local processing, no cloud dependencies or data transmission
- π Compliance Metrics - Real-time safety compliance reporting and audio alerts
- π― Multi-PPE Detection - Detects helmets, masks, safety vests, and violations
- Python 3.8+ (3.12 recommended)
- Webcam (for live detection)
- ~4GB disk space for virtual environment and dependencies
# Clone the repository
git clone <repository-url>
cd security-checker
# Activate the dedicated YOLO virtual environment
source yolo_env/bin/activate # On macOS/Linux
# OR
yolo_env\Scripts\activate # On Windows
# Install additional dependencies if needed
pip install -r requirements.txt
# Run the application
streamlit run .streamlit/app.pyβββ .streamlit/ # Streamlit applications
β βββ 01_home.py # Landing page and navigation
β βββ 02_image.py # Image analysis interface
β βββ 03_video.py # Video processing with tracking
β βββ 04_live.py # Live webcam detection
βββ utils/ # Core utility modules
β βββ __init__.py # Package initialization
β βββ config.py # Environment configuration
βββ model/ # Local trained YOLO model
β βββ best.pt # Custom PPE detection model
βββ assets/ # Static assets
β βββ logo.webp # Application logo
β βββ emergency-alarm.mp3 # Audio alert sound
βββ yolo_env/ # Dedicated virtual environment
β βββ bin/ # Environment executables
β βββ lib/ # Python packages
β βββ ... # Virtual environment files
βββ notebooks/ # Development notebooks
β βββ ppe_v1.ipynb # Model development
β βββ ppe_v2.ipynb # Model training iterations
βββ requirements.txt # Python dependencies
βββ docker-compose.yaml # Docker deployment (optional)
βββ README.md # This file
The system uses environment-based configuration with sensible defaults:
- Local Model:
model/best.pt- Custom-trained PPE detection model - Detection Classes: Helmet, Mask, Safety Vest, Person, and violation classes
- Confidence Threshold: Adjustable per-page (default varies by use case)
The app uses a dedicated virtual environment (yolo_env/) with optimized dependencies:
- PyTorch: GPU-accelerated inference (when available)
- Ultralytics YOLO: Latest YOLO implementation
- OpenCV: Computer vision processing
- Streamlit: Web interface framework
The custom-trained model detects the following PPE items and violations:
- πͺ Helmet/Hard Hat - Safety headgear compliance
- π· Mask - Face covering detection
- π¦Ί Safety Vest - High-visibility clothing detection
- π€ Person - Human detection for context
- NO-Helmet - Missing headgear violations
- NO-Mask - Missing face covering violations
- NO-Safety Vest - Missing vest violations
- Safety Cone - Work zone markers
- Machinery - Industrial equipment
- Vehicle - Construction vehicles
The system uses direct integration with a custom-trained YOLO model:
# Custom model trained specifically for PPE detection
# Optimized for construction and industrial environments
# Real-time processing with dedicated virtual environmentArchitecture Benefits:
- Custom Training - Model specifically trained on PPE scenarios
- Fast Inference - Direct model access with optimized environment
- No Network Dependencies - Completely offline processing
- Memory Efficient - Model loads once and stays in memory
- Privacy Focused - No data transmission to external services
- Real-time Tracking - DeepSORT integration for person tracking in videos
- Compliance Metrics - Continuous calculation based on all 3 PPE items
- Audio Alerts - Customizable sound notifications for violations
- Multi-format Support - Images, videos, and live webcam streams
- Navigate to the Image Analysis page
- Upload an image file (JPG, PNG, etc.)
- Adjust confidence threshold as needed
- View detection results and compliance metrics
- Download annotated image with bounding boxes
- Go to the Video Processing page
- Upload a video file (MP4, AVI, MOV, etc.)
- Configure detection parameters and playback speed
- Process video with frame-by-frame analysis
- Monitor real-time compliance metrics during processing
- Download processed video with annotations
- Go to the Live Detection page
- Allow camera access when prompted by browser
- Adjust detection settings and persistence
- Monitor real-time PPE compliance
- Enable audio alerts for immediate violation notifications
- Current Model: Custom-trained on PPE datasets
- Model Location:
model/best.pt - Training Notebooks: Available in
notebooks/directory - Model Updates: Replace
best.ptwith new trained models
- Retrain model with new classes
- Update color mapping in utility functions
- Modify compliance calculation logic
- Update UI class displays and icons
- β Custom Model Training - Dedicated PPE model trained on construction datasets
- β
Dedicated Virtual Environment - Optimized dependency management with
yolo_env/ - β Enhanced Live Detection - Continuous compliance tracking with audio alerts
- β Video Processing Improvements - DeepSORT tracking and real-time metrics
- β Privacy-First Architecture - Complete offline processing, no external dependencies
- β Streamlined Interface - Clean, focused UI without unnecessary model status messages
- β Real-time Compliance - Dynamic metrics that update as PPE is added/removed
- β Audio Alert System - Customizable sound notifications for safety violations
- Activate Environment: Ensure
yolo_envis activated before running - Dependencies: Check
requirements.txtfor any missing packages - Python Version: Use Python 3.8+ (3.12 recommended)
- Model Location: Verify
model/best.ptexists and is accessible - Model Format: Ensure model is compatible with Ultralytics YOLO
- Memory: Ensure sufficient RAM (4GB+ recommended)
- GPU Acceleration: PyTorch will use GPU if available (CUDA/MPS)
- Detection Interval: Increase interval for slower hardware
- Confidence Threshold: Adjust for optimal detection vs. performance balance
- Permissions: Allow camera access in browser settings
- Browser Support: Use Chrome, Firefox, Safari, or Edge
- WebRTC: Ensure browser supports WebRTC for live detection
- Refresh: Try refreshing the page or restarting Streamlit
For containerized deployment, use the included Docker configuration:
# Build and run with Docker Compose
docker-compose up --build
# Access the application at http://localhost:8501- Model Improvements: Train new models with additional PPE classes
- Performance Optimization: Enhance inference speed and accuracy
- UI/UX Enhancements: Improve user interface and experience
- Documentation: Update documentation and examples
This project is designed for educational and safety monitoring purposes. Please ensure compliance with local privacy and surveillance regulations when deploying in workplace environments.
