Construction sites are dangerous places where accidents can happen at any time. Therefore, it is important to keep workers safe by enforcing safety measures, such as helmet use. However, monitoring worker compliance can be a challenging task. This is where a detection model can come in handy.

 

In this tutorial, you will build a detection model that can detect whether or not workers on a construction site are wearing helmets.

 

To create the model, use the publicly available Safety Helmet Detection dataset, which contains 5000 images with bounding box annotations for 3 classes: helmet, person, and head.

 

#Adding the dataset

 

Go to the Owned datasets and click Add new dataset. Enter a dataset name, select Personal the dataset type, and click Create.

 

Create dataset
Create dataset

 

The Safety Helmet Detection dataset has been saved in a .zip archive consisting of two folders: annotations and images. You can upload it either as an archive or as a directory. For this tutorial, we will use the second option. Click Add directory.

 

Upload view
Upload view

 

Wait for the site to validate the uploaded directory.

 

Validation process
Validation process

 

In the thumbnails, you will see the images with added annotations. Once the directory is loaded, click Upload.

 

Upload directory
Upload directory

 

Before uploading, you will be informed of our image size limits. Decide what the application should do if the size limit is exceeded. For this tutorial select Scale.

 

Image limits
Image limits

 

The uploading task is performed in the background. You can monitor the progress of the Dashboard or Datasets view.

 

Dashboard view
Dashboard view

 

#Creating the model

 

Go to the Models section and click Add new model. Select Detection.

 

Add new model
Add new model

 

From the Safety Helmet dataset select helmet and head categories.

 

Choose dataset and categories
Choose dataset and categories

 

Skip the merge categories step and click Next. Enter the name of your model and select the Darknet framework.

 

Set model parameters
Set model parameters

 

Choose the Configure manually option. Click Next.

 

Configuration
Configuration

 

Change the pre-trained model to yolo4-tiny.conv.29 and click Start training. You can view the training progress in the Dashboard view, in the Notifications tab, or in the Models section.

 

#Testing your idea

 

Once the training is complete, go to the Models section.

 

Models section
Models section

 

Click on the Safety Helmet Detector model to run it.

 

Select hardware
Select Hardware

 

Select the NVIDIA MAXWELL architecture. Click the hardware tile to convert.

 

Select device
Select device

 

Once converted, click on the device to connect to it.

 

Connect to the device
Connect to the device

 

Copy the registration code to the clipboard, then click Copy token and go to device. This will open a new tab in your browser, where you will find a web app that is now using your local Nano device.

 

AIDWS
AIDWS

 

Enter your e-mail, paste your registration code into the Token field, and create a password. Once registered, the device will change its status to Connected in the Live Testing section of the OSAI app.

 

Download model
Download model

 

Click on the model tile to download it to the device's local memory. Click on the model again and select the input data required to test the model. Click the Upload File button. You can upload either a photo or a video. For the purpose of this tutorial, we will use two different video files.

 

Upload file
Upload file

 

Once your video file has been uploaded, you can change its settings and decide whether or not to create a new dataset with the uploaded videos. Click Next to continue.

 

Settings
Settings

 

After the video is processed by the web app, you can view the results.

 

#Results

 

Results
Results
Results
Results

 

Keep in mind You can always improve the effectiveness of the trained model by subjecting it to a re-training process.