A real-time Personal Protective Equipment (PPE) detection system using YOLOv8 and computer vision. This application helps monitor workplace safety by detecting safety equipment like helmets, vests, gloves, and other protective gear through webcam or video streams.
- π₯ Real-time Detection: Live webcam feed with instant PPE detection
- π High Performance: Optimized detection intervals for smooth performance
- π― Accurate Recognition: YOLOv8-based model for reliable PPE detection
- π Safety Logging: Track and log safety violations
- π Web Interface: User-friendly browser-based interface
- β‘ WebSocket Communication: Real-time bidirectional data streaming
- π§ Customizable: Adjustable detection parameters and thresholds
Add your demo video or GIF here
Add sample detection images here
Input Output
Before you begin, ensure you have the following installed on your system:
- Python 3.11.9 (recommended for optimal compatibility)
- Git (for cloning the repository)
- pip (Python package installer)
- Webcam/Camera (for live detection)
- OS: Linux, macOS, or Windows
- RAM: Minimum 4GB (8GB recommended)
- Storage: ~2GB for dependencies and models
git clone https://github.com/yourusername/protego.git
cd protego# On Linux/macOS
python3.11 -m venv myenv
source myenv/bin/activate
# On Windows
python -m venv myenv
myenv\Scripts\activatepython --version
# Should output: Python 3.11.9Navigate to the backend directory and install required packages:
cd backend
pip install --upgrade pip
pip install -r requirements.txtNote: This will install:
- FastAPI & Uvicorn (Web framework)
- PyTorch (CPU version for deep learning)
- Ultralytics YOLO (Object detection)
- OpenCV (Computer vision)
- NumPy (Numerical computing)
- WebSockets (Real-time communication)
Ensure the YOLO model is present:
ls models/ppe_yolo.ptIf the model file is missing, you'll need to obtain it or train your own PPE detection model.
- Activate the virtual environment (if not already activated):
# On Linux/macOS
source ../myenv/bin/activate
# On Windows
..\myenv\Scripts\activate- Navigate to the backend directory:
cd backend- Start the server:
uvicorn main:app --host 127.0.0.1 --port 8080You should see output similar to:
π¦ Loaded PPE classes: {0: 'Hardhat', 1: 'Mask', 2: 'NO-Hardhat', 3: 'NO-Mask', 4: 'NO-Safety Vest', 5: 'Person', 6: 'Safety Cone', 7: 'Safety Vest', 8: 'machinery', 9: 'vehicle'}
INFO: Started server process [ ]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)
- Open your web browser
- Navigate to:
http://127.0.0.1:8080 - Allow camera access when prompted
- The live detection feed will start automatically
- Start Detection: The system automatically starts detecting PPE when you access the page
- View Results: Detected objects are highlighted with bounding boxes and labels
- Safety Logs: Violations and detections are logged in real-time
- Stop Detection: Simply close the browser tab or stop the server (CTRL+C)
You can customize the detection parameters in backend/main.py:
# Performance Controls
DETECT_INTERVAL = 0.25 # Detection frequency (seconds)
RESULT_TTL = 0.6 # Result time-to-live (seconds)
JPEG_QUALITY = 65 # Image quality (1-100)
VIOLATION_COOLDOWN = 2.0 # Cooldown between violation alerts (seconds)assistive_vision/
βββ backend/
β βββ main.py # FastAPI application & WebSocket server
β βββ detector.py # Detection logic (legacy/unused)
β βββ requirements.txt # Python dependencies
β βββ Procfile # Deployment configuration
β βββ models/
β β βββ ppe_yolo.pt # YOLOv8 PPE detection model
β βββ static/
β βββ index.html # Web interface
βββ myenv/ # Virtual environment (not in git)
βββ runtime.txt # Python version specification
βββ LICENSE # Project license
βββ README.md # Docs
1. Camera not accessible
- Ensure your browser has permission to access the webcam
- Check if another application is using the camera
- Try a different browser (Chrome/Firefox recommended)
2. Module not found errors
# Ensure virtual environment is activated
source myenv/bin/activate # Linux/macOS
myenv\Scripts\activate # Windows
# Reinstall dependencies
pip install -r backend/requirements.txt3. Port already in use
# Use a different port
uvicorn main:app --reload --port 80814. Slow performance
- Reduce
DETECT_INTERVALin main.py - Lower
JPEG_QUALITYfor faster transmission - Ensure CPU resources are available
uvicorn main:app --host 0.0.0.0 --port 8080 --workers 4Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your 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
This project is licensed under the terms specified in the LICENSE file.
PrasanthPradeep(https://github.com/PrasanthPradeep/)
- Ultralytics YOLOv8 for the object detection framework
- FastAPI for the web framework
- OpenCV for computer vision capabilities
If you encounter any issues or have questions:
- Open an Issue




