DEMO: https://huggingface.co/spaces/hafizqaim/Workspace-Safety-Detection
This project provides a real-time object detection system to monitor whether people in a workplace environment are wearing essential Personal Protective Equipment (PPE), specifically safety helmets and vests. The system is built using the YOLOv8 model.
- Real-Time Detection: Capable of processing video streams from files or a live webcam to identify PPE in real-time.
- High Accuracy: Trained on a large dataset of over 23,000 images, achieving an mAP50 of 73.5% overall and over 86% for key classes like helmets and vests.
- State-of-the-Art Model: Utilizes YOLOv8, a powerful and efficient object detection architecture.
- Focused Detection: While trained on 17 classes, the inference script is configured to specifically highlight helmets and vests for workplace safety monitoring.
- Python 3.8+
- PyTorch
- Ultralytics YOLOv8
- OpenCV
- Kaggle Notebooks (for training)
Follow these instructions to set up and run the project on your local machine.
- Python 3.8 or newer
- Git
-
Clone the repository:
git clone [https://github.com/hafizqaim/Workspace-Safety-Detection-using-YOLOv8.git](https://github.com/hafizqaim/Workspace-Safety-Detection-using-YOLOv8.git) cd Workspace-Safety-Detection-using-YOLOv8
-
Create and activate a virtual environment:
# For macOS/Linux python3 -m venv venv source venv/bin/activate # For Windows python -m venv venv .\venv\Scripts\activate
-
Install the required packages:
pip install -r requirements.txt
-
Download the Trained Model: The trained model file (
best.pt
) is required to run the inference. Download it from the Releases page of this repository. -
Place the Model: Place the downloaded
best.pt
file in the root directory of the project. -
Run the Inference Script: The
inference.py
script is configured to run on your webcam by default.python inference.py
- To use a video file instead, open
inference.py
and modify the script to point to your video file.
- To use a video file instead, open
The model was trained for 10 epochs on the "PPE Detection v3" dataset from Roboflow.
Class | Precision | Recall | mAP50 | mAP50-95 |
---|---|---|---|---|
Overall | 0.72 | 0.715 | 0.735 | 0.456 |
head_helmet |
0.784 | 0.824 | 0.866 | 0.584 |
vest |
0.841 | 0.897 | 0.935 | 0.705 |

