Seatbelt Detection#

Setup#

Given the driver-facing video, the seatbelt detection module uses an object detection pipeline to detect the seatbelt on the driver.

In order to run the seatbelt module on the front facing video(let’s call it front_video.mp4), first add a file named seatbelt.yml to your current folder.

seatbelt.yml(click to open/close)
device: "cpu"
skip_frames: 25
classifier_confidence_threshold: 0.75
detection_percentage: 0.75
model_path: ["models", "seatbelt_model.pth"]
Explanation of the above configuration values(click to open)

Parameter

Description

Example Value

device

Hardware for pytorch to run the model inference on

“cpu” or “cuda:0”

skip_frames

Number of frames to skip(integer)

25

classifier_confidence_threshold

Threshold to classify seatbelt detection(float)

0.75

detection_percentage

Percentage number of detections to consider the test as pass(float)

0.75

model_path

path to the saved model. Format: [‘directory’, ‘file_name’]

[“models”, “seatbelt_model.pth”]

Now, run the following command:

python main.py --seat-belt front_video.mp4 --config seatbelt.yml --output-path results/

The following notebook has a code-walkthrough to run the Seatbelt module and visualize the results:

Running the seatbelt code on driver-facing video.