CoolFace
Apppublic

ayjee99/ppe-detection-system

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes
App README

๐Ÿฆบ 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

  1. 1.Go to "Video Upload" tab
  2. 2.Upload your construction site video (MP4, AVI, MOV)
  3. 3.Adjust detection confidence threshold (default: 0.25)
  4. 4.Enable/disable zones and alerts
  5. 5.Click "Start Processing"
  6. 6.Download annotated video and violation reports

๐Ÿ“ท Live Camera Mode

  1. 1.Go to "Live Camera" tab
  2. 2.Enter camera source:
  3. 3.0 for default webcam
  4. 4.rtsp://username:password@ip:port/stream for IP camera
  5. 5.Click "Test Connection" to verify
  6. 6.Click "Start Live Feed"
  7. 7.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

HardwareVideo ProcessingLive Camera
GPU (T4)20-30 FPS15-25 FPS
CPU5-8 FPS3-5 FPS

๐Ÿ› ๏ธ 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