Automated Safety Compliance Through Computer Vision
Safety rule violations, like not wearing helmets, are hard to track manually. A computer vision system can automate helmet compliance monitoring, enhance workplace safety, and reduce accident severity without needing extra staff.
Traditional manual safety monitoring faces several challenges:
- Human Error: Manual oversight can miss violations
- Resource Intensive: Requires dedicated safety personnel
- Inconsistent Monitoring: Cannot provide 24/7 surveillance
- Delayed Response: Violations detected after incidents occur
- Documentation Issues: Difficult to maintain compliance records
Our AI-powered system provides:
- Real-time Detection: Instant helmet compliance verification
- Automated Monitoring: Continuous surveillance without human intervention
- Accurate Documentation: Automated violation logging and reporting
- Cost-effective: Reduces need for additional safety staff
- Scalable: Can monitor multiple locations simultaneously
- Real-time Helmet Detection - Instant compliance verification
- Live Camera Integration - Continuous monitoring through webcam/IP cameras
- Batch Image Processing - Analyze multiple images simultaneously
- High Accuracy - Advanced AI model with adjustable confidence thresholds
- Violation Logging - Automatic incident recording with timestamps
- Compliance Reporting - Generate detailed safety compliance reports
- Statistics Dashboard - Track compliance rates and trends
- Export Functionality - Download reports in CSV format
- Intuitive Web Interface - Easy-to-use Streamlit dashboard
- Adjustable Thresholds - Customize detection sensitivity
- Multiple Input Methods - Upload images, use camera, or batch process
- Real-time Feedback - Instant safety status notifications
- Construction Sites - Monitor workers in hard hat zones
- Manufacturing Plants - Ensure safety compliance in production areas
- Warehouses - Automated safety checks in material handling zones
- Mining Operations - Critical safety monitoring in hazardous environments
- Reduced Accidents - Proactive safety violation prevention
- Lower Insurance Costs - Improved safety records
- Regulatory Compliance - Meet OSHA and safety standards
- Enhanced Productivity - Automated monitoring frees staff for other tasks
- Python: 3.8 or higher
- RAM: Minimum 4GB (8GB recommended)
- Storage: 500MB free space
- Camera: Optional (for live detection)
streamlit==1.28.0
tensorflow==2.13.0
opencv-python==4.8.0.74
Pillow==10.0.0
numpy==1.24.3
pandas==2.0.3
git clone https://github.com/HarshitBhalani/Helmet-Compliance-Monitoring.git
cd Helmet-Compliance-Monitoring# Windows
python -m venv helmet_env
helmet_env\Scripts\activate
# macOS/Linux
python -m venv helmet_env
source helmet_env/bin/activatepip install -r requirements.txtOption A: Train Your Own Model
- Visit Google Teachable Machine
- Create image classification project
- Upload helmet/no-helmet training images
- Train and export as TensorFlow model
- Download and rename to
model.h5 - Place in project root directory
Option B: Use Pre-trained Model (If Available)
- Contact repository maintainer for model file
- Place
model.h5in project root directory
streamlit run app.pyOpen your browser and navigate to: http://localhost:8501
- Select "π· Image Upload" mode
- Upload an image file (JPG, PNG, BMP)
- View detection results and confidence scores
- System automatically logs violations
- Select "πΉ Live Camera" mode
- Allow camera permissions
- Capture photos for real-time analysis
- Get instant safety compliance feedback
- Select "π Batch Processing" mode
- Upload multiple images at once
- Generate comprehensive compliance report
- Export results for documentation
- Select "π Violation Logs" mode
- Review all detected violations
- Analyze compliance trends
- Export data for regulatory reporting
- 0.5-0.6: Lenient (reduces false violations, may miss some cases)
- 0.7: Balanced (recommended for most environments)
- 0.8-0.9: Strict (ideal for high-risk environments)
- Adjust threshold based on your safety requirements
- Higher thresholds for critical safety zones
- Lower thresholds for general monitoring areas
- Architecture: Convolutional Neural Network (CNN)
- Input Size: 224x224 pixels
- Classes: 2 (With Helmet, Without Helmet)
- Framework: TensorFlow/Keras
- Training: Supervised learning on labeled helmet images
- Accuracy: Depends on training data quality
- Processing Speed: Real-time capability
- Memory Usage: Optimized for standard hardware
β
HELMET DETECTED - COMPLIANT
Status: SAFE β
Confidence Level: 89.2%
β NO HELMET DETECTED - VIOLATION
Status: UNSAFE β οΈ
Confidence Level: 94.7%
π¨ SAFETY VIOLATION ALERT
Immediate Actions Required:
- π Stop work immediately
- πͺ Provide safety helmet
- π Brief worker on safety protocols
- π Document the incident
helmet_streamlit_app/
βββ model/ # Model directory
β βββ model.json # Model architecture in JSON format
β βββ metadata.json # Model metadata and configuration
β βββ weights.bin # Model weights in binary format
βββ app.py # Main Streamlit application
βββ requirements.txt # Python dependencies
βββ labels.txt # Class labels for model
βββ README.md # Project documentation
βββ .gitignore # Git exclusion rules
βββ model.h5 # Complete Keras/TensorFlow model file
- Local Processing: All detection happens on your local machine
- No Data Upload: Images are not sent to external servers
- Privacy Compliant: Suitable for sensitive workplace environments
- Secure Logging: Violation logs stored locally
- Run on local machine for single-user access
- Ideal for testing and small-scale monitoring
- Deploy on internal server for multi-user access
- Access from multiple devices on same network
- Deploy on Streamlit Cloud, Heroku, or AWS
- Requires model hosting solution (Google Drive, etc.)
Model Loading Error
β model.h5 file not found!
Solution: Ensure model.h5 is in the project root directory
Camera Access Error
Permission denied for camera access
Solution: Grant camera permissions in browser settings
Low Detection Accuracy
Many false positives/negatives
Solution: Adjust detection threshold or retrain model with better data
- Use GPU-enabled TensorFlow for faster processing
- Optimize image resolution for speed vs accuracy balance
- Consider model quantization for mobile deployment
We welcome contributions to improve the system!
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Model accuracy improvements
- Additional safety equipment detection
- Mobile app development
- Integration with IoT devices
- Advanced analytics features
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Report bugs via GitHub Issues
- Discussions: Join project discussions
- Email: [harshitbhalani187@gmail.com]
Q: Can this detect other safety equipment? A: Currently focused on helmets, but can be extended for vests, gloves, etc.
Q: What accuracy can I expect? A: Depends on training data quality, typically 85-95% with good data.
Q: Can it work with IP cameras? A: Yes, with minor code modifications for RTSP streams.
Q: Is it suitable for outdoor use? A: Yes, but performance may vary with lighting conditions.
- TensorFlow Team for the amazing ML framework
- Streamlit for the intuitive web app framework
- OpenCV for computer vision capabilities
- Google Teachable Machine for accessible model training
- Multi-person detection in single image
- Integration with existing security systems
- Mobile application development
- Advanced analytics and predictive insights
- Support for multiple safety equipment types
- Real-time video stream processing
- Database integration for enterprise use
- API development for third-party integrations
β‘ Automated Safety Monitoring for a Safer Workplace β‘
Made with β€οΈ for workplace safety