Enhancing Construction Worker Safety with AI

Oct 18, 2024

Dataset Preperation

Construction sites are hazardous environments to work, and accidents often occur due to insufficient safety measures. One critical aspect of worker safety is the use of Personal Protective Equipment (PPE), which can significantly reduce the risk of injuries. To ensure compliance with safety protocols and prevent accidents, it’s essential to monitor workers’ PPE usage in real-time.

Advancements in computer vision and object detection have made it possible to automate the identification of PPE compliance among construction workers. By training a model on a dataset of images depicting workers in various safety scenarios, we can accurately detect the presence or absence of different types of PPE.

Our object detection model can be applied to a variety of real-world scenarios to enhance construction site safety:

  • Real-Time Alerts: Immediate notification when a safety violation is detected, allowing for prompt corrective action.

  • Site Access Control: Integrating the model with entry systems to ensure all personnel are equipped with necessary safety gear before entering hazardous zones.

  • Safety Audits: Automating the documentation of safety compliance for regulatory reporting.

In this blog, we’ll guide you through the process of building this object detection model using our no-code platform at Matrice. We’ll cover:

  1. Dataset Preparation

  2. Dataset Annotation

  3. Model Training

  4. Model Evaluation

  5. Model Inference

  6. Model Deployment

Dataset Preparation

The model is trained on a dataset that includes 3,199 images, categorized into the following classes:

  • Helmet: Detects workers wearing safety helmets.

  • No Helmet: Detects workers not wearing helmets.

  • Vest: Detects workers with safety vests.

  • No Vest: Detects workers without safety vests.

  • Person: Detection of individuals on-site.

The data is split into training, testing, and validation sets following a 70:20:10 ratio. This ensures that the model has sufficient data for learning, testing, and fine-tuning to generalize well on unseen examples.

Dataset Preperation

Dataset Preview

Dataset Annotation

Since our dataset was already annotated, there was no need for a separate annotation task, saving us significant time and effort. The annotations were prepared in MSCOCO, a format compatible with our platform, making it easy to proceed directly with training.

Annoatation Preview

Model training

To find the optimal configuration for our object detection model, we conducted a series of experiments using different versions of YOLOv8 models, specifically YOLOv8n, YOLOv8s, and YOLOv8m. We experimented with various batch sizes and epochs to determine the best performance for detecting PPE compliance.

After analyzing the performance of the different models, we found that the YOLOv8s model with the following configuration achieved the best results for the primary metric, precision:

  • Batch Size: 16

  • Epochs: 200

  • Learning Rate (lr): 0.001

  • Optimizer: Auto

  • Momentum: 0.95

  • Weight Decay: 0.0005

Models Preview

Performance Metrics

The chosen model was evaluated on both the validation and test sets, resulting in the following metrics:

Category

Precision

Recall

Validation

Test

Validation

Test

all

0.856

0.826

0.717

0.735

helmet

0.885

0.896

0.789

0.852

no-helmet

0.683

0.611

0.410

0.423

no-vest

0.876

0.807

0.673

0.662

person

0.918

0.916

0.897

0.899

vest

0.919

0.899

0.815

0.839

Model Training Dashboard and Results

  • Model Performance by Category:

    This graph visualizes the performance of the model across different categories such as helmet, no-helmet, vest, and no-vest. As seen, the WorkerSafety-1 model achieved the best test precision for detecting helmets.

Models Preview

  • Training Analysis for Loss:

    This plot tracks the loss during model training, indicating stability in the loss values as the epochs progress. The consistent loss values demonstrate well-tuned hyperparameters for the training process.

Models Preview

  • Training Analysis for Recall:

    The graph illustrates the model’s recall across epochs, showing a recall of around 0.71 for the validation set. This demonstrates the model’s ability to identify true positives with high accuracy throughout the training process.

Models Preview

  • Model Test

Our platform provides an intuitive model testing feature. Simply drag and drop images into the testing interface, and the platform will generate predictions, giving you quick insights into the model’s performance.

Models Preview

Models Preview

These results indicate that the YOLOv8s model is well-suited for detecting PPE compliance with a strong emphasis on precision, ensuring that safety violations are accurately detected with minimal false positives.

Model Inference

One of the key features of our platform is the ability to export your trained models from the default PyTorch (.pt) format to a variety of other formats, including ONNX, TensorRT, and OpenVINO. This flexibility is crucial because not all environments have access to powerful compute resources.

For instance, on a construction site, the available hardware may not be capable of efficiently running models in the PyTorch (.pt) format, which can require significant GPU resources. In such cases, customers can convert their models to ONNX or OpenVINO formats, which are optimized to run on lower-end machines. This ensures that the models can be deployed in real-world scenarios without the need for high-performance computing infrastructure.

Conversely, in environments with extensive compute resources, customers can convert models to specific formats like TensorRT, enabling them to fully leverage the available hardware for maximum performance. This flexibility allows users to tailor the model format to their particular needs, ensuring efficient deployment regardless of the resources available.

Ultimately, this feature provides customers with the ability to adapt their models to their unique settings and resource constraints, whether it’s a low-powered device or a high-end machine.

Inference Preview

Model Deployment

Our platform allows you to seamlessly deploy your trained or exported models. After deployment, our specialized servers handle all the computation, so you can sit back, upload images, and receive predictions almost instantly.

Our platform also offers boilerplate API integration code for a wide range of programming languages, including Python, JavaScript, PHP, Golang, and more. This ensures flexibility, allowing you to incorporate the deployed models into various applications, whether it’s a web service, mobile app, or custom software solution.

By offloading the computational heavy lifting to our servers, you can ensure fast, reliable, and scalable inference, no matter the complexity of your model or the constraints of your local environment.

Deployment Preview

Deployment Preview

Conclusion

Advancements in computer vision have enabled more proactive construction safety measures. Using our no-code platform, object detection models can easily identify PPE compliance in real-time, enhancing site safety.

Our platform simplifies the process from dataset preparation to model deployment, providing an adaptable solution for real-world needs. Start your journey today and create a safer construction site.

Think CV, Think Matrice

Experience 40% faster deployment and slash development costs by 80%