Skip to content

PrasanthPradeep/protego

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Protego Logo Protego - I Protect. The Shield for Workers.

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.

✨ Features

  • πŸŽ₯ 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

🎬 Demo

Add your demo video or GIF here

Demo Screenshot

Sample Detections

Add sample detection images here

Input Output
Sample 1 Detection 1
Sample 2 Detection 2

πŸ› οΈ Prerequisites

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)

System Requirements

  • OS: Linux, macOS, or Windows
  • RAM: Minimum 4GB (8GB recommended)
  • Storage: ~2GB for dependencies and models

πŸ“₯ Installation

1. Clone the Repository

git clone https://github.com/yourusername/protego.git
cd protego

2. Set Up Python Environment

Create a Virtual Environment

# On Linux/macOS
python3.11 -m venv myenv
source myenv/bin/activate

# On Windows
python -m venv myenv
myenv\Scripts\activate

Verify Python Version

python --version
# Should output: Python 3.11.9

3. Install Dependencies

Navigate to the backend directory and install required packages:

cd backend
pip install --upgrade pip
pip install -r requirements.txt

Note: 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)

4. Verify Model Files

Ensure the YOLO model is present:

ls models/ppe_yolo.pt

If the model file is missing, you'll need to obtain it or train your own PPE detection model.

πŸš€ Usage

Starting the Application

  1. Activate the virtual environment (if not already activated):
# On Linux/macOS
source ../myenv/bin/activate

# On Windows
..\myenv\Scripts\activate
  1. Navigate to the backend directory:
cd backend
  1. Start the server:
uvicorn main:app --host 127.0.0.1 --port 8080

You 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)

Accessing the Application

  1. Open your web browser
  2. Navigate to: http://127.0.0.1:8080
  3. Allow camera access when prompted
  4. The live detection feed will start automatically

Using the Interface

  • 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)

βš™οΈ Configuration

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)

πŸ“ Project Structure

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

πŸ› Troubleshooting

Common Issues

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.txt

3. Port already in use

# Use a different port
uvicorn main:app --reload --port 8081

4. Slow performance

  • Reduce DETECT_INTERVAL in main.py
  • Lower JPEG_QUALITY for faster transmission
  • Ensure CPU resources are available

🚒 Deployment

Deploy Locally with Production Settings

uvicorn main:app --host 0.0.0.0 --port 8080 --workers 4

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the terms specified in the LICENSE file.

πŸ‘¨β€πŸ’» Author

PrasanthPradeep(https://github.com/PrasanthPradeep/)

πŸ™ Acknowledgments

πŸ“ž Support

If you encounter any issues or have questions:


⚠️ Safety Notice: This system is designed to assist with safety monitoring but should not be relied upon as the sole method of ensuring workplace safety compliance. Always follow proper safety protocols and guidelines.

About

I Protect. The Shield for Workers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published