ayjee99/ppe-detection-system
๐ฆบ PPE Compliance Detection System
Real-time Personal Protective Equipment (PPE) violation detection for construction sites using YOLOv9 and DeepSORT tracking.
๐ฏ Features
- โ Real-time PPE Detection - Detects 17 classes (helmet, gloves, vest, shoes, etc.)
- โ Multi-Person Tracking - DeepSORT maintains persistent worker IDs
- โ Temporal Logic - 3-second threshold eliminates 80%+ false positives
- โ Zone-Based Rules - Different areas enforce different PPE requirements
- โ Dual Input Support - Process video files OR live camera feeds
- โ Real-Time Alerts - Visual and audio notifications for violations
- โ Auto Reports - CSV and text reports generated automatically
- โ Web Interface - User-friendly Gradio interface
๐ How to Use
๐น Video Upload Mode
- Go to "Video Upload" tab
- Upload your construction site video (MP4, AVI, MOV)
- Adjust detection confidence threshold (default: 0.25)
- Enable/disable zones and alerts
- Click "Start Processing"
- Download annotated video and violation reports
๐ท Live Camera Mode
- Go to "Live Camera" tab
- Enter camera source:
0for default webcamrtsp://username:password@ip:port/streamfor IP camera- Click "Test Connection" to verify
- Click "Start Live Feed"
- Real-time violations will be displayed with alerts
โ ๏ธ Note: Audio alerts don't work on HF Spaces (no audio output). Live camera may not work in browser - use video upload mode.
๐ Model Information
- Architecture: YOLOv9-e
- Dataset: SH17 (8,099 images, 17 classes)
- Performance: mAP@0.5 = 70.9%
- Optimization: FP16 precision for 2x GPU speedup
๐ฆ Classes Detected
PPE Items (11 classes)
helmet, gloves, safety-vest, shoes, earmuffs, face-guard, face-mask-medical, glasses, medical-suit, safety-suit, tools
Body Parts (6 classes)
person, head, face, hands, feet, ears
โ๏ธ How It Works
Video/Camera Input โ YOLOv9 Detection (17 classes) โ DeepSORT Tracking (Persistent IDs) โ Proximity Checker (Body โ PPE Association) โ Zone Checker (Location-Based Rules) โ Temporal Logic (3-second threshold) โ Alert Manager (Visual + Audio) โ Annotated Video + Reports
text
๐ Violation Detection Logic
Proximity-Based Association
- Checks if PPE items are within 100 pixels of corresponding body parts
- Example: helmet near head, gloves near hands
Temporal Threshold (CRITICAL)
- Violation must persist for 3 seconds before alerting
- Eliminates false positives from momentary occlusions
- Result: 80%+ reduction in false alarms
Zone-Based Rules
- Different zones enforce different PPE requirements
- High Risk Zone: helmet + gloves + earmuffs + vest
- Welding Zone: helmet + gloves + face-guard + vest
- General Area: helmet + gloves + vest
๐ Performance
๐ ๏ธ Configuration
The system can be customized via config/settings.json:
- Detection confidence threshold
- Proximity threshold for PPE association
- Temporal threshold (default: 3 seconds)
- Zone definitions and requirements
๐ Output Reports
- CSV Report: Structured data with all violations
- Text Report: Human-readable summary with statistics
- Annotated Video: Visual output with bounding boxes and alerts
โ ๏ธ Limitations on HF Spaces
- Audio alerts don't work (no audio output in browser)
- Live camera access may be restricted by browser security
- GPU needed for real-time performance (request upgrade in Settings)
๐ก Use Cases
- Construction site safety monitoring
- Manufacturing facility compliance
- Industrial workplace safety
- Training and demonstration
- Safety audit documentation
๐ค Contributing
Contributions welcome! This is an open-source project for construction safety.
๐ Technologies Used
- YOLOv9 - Object detection
- DeepSORT - Multi-object tracking
- Gradio - Web interface
- OpenCV - Video processing
- PyTorch - Deep learning framework
๐ Support
For issues or questions, please open an issue on the GitHub repository.
Built for Construction Safety ๐๏ธ | Powered by YOLOv9 ๐
Version: 1.0.0
