This repository implements KiD3 introduced in the paper Towards Infusing Auxiliary Knowledge for Distracted Driver Detection which was accepted by KiL'24: Workshop on Knowledge-infused Learning co-located with 30th ACM KDD Conference, August 26, 2024, Barcelona, Spain
This repository presents the implementation of KiD3, a novel method for distracted driver detection (DDD) by infusing auxiliary knowledge about semantic relations between entities in a scene and the structural configuration of the driver's pose. Specifically, a unified framework that integrates the scene graphs, and driver's pose information with the visual cues in video frames to create a holistic representation of the driver's actions.
Install the Python dependencies (Python 3.9+ recommended):
pip install -r requirements.txtThis project also builds on two external repositories:
-
Clone the RelTR repository into the
RelTRfolder of this repository and replace theinference.pyfile with the one provided in theRelTRfolder of this repository. Make sure to follow the installation instructions provided in the RelTR repository (including downloading the pre-trained models). -
Similarly, clone the OpenPose repository into the
Openposefolder of this repository and add theopenpose.pyfile provided in theOpenposefolder of this repository. Make sure to follow the installation instructions provided in the OpenPose repository (including downloading the pre-trained models).
-
Download the SynDD1 dataset by filling up the form here and annotate every frame with the corresponding driver's action label and save the frames in
'{user_id}_{minute}_{second}_{label}.jpg'format. Do this for all videos in the dataset and save them in theDatasets/annotatedvideosv1/AnnotatedVideos/{video_name}folder. -
Extract the scene graphs for each frame by running
Preprocessing/scene_graph.py. Running this will create a sceneGraphs.json file in each of the Datasets/annotatedvideosv1/AnnotatedVideos/{video_name} folders corresponding to each video. Make sure you have a GPU on your device, else this won't run. -
Steps to extract pose information:
- Download the body_pose_model.pth and hand_pose_model.pth files from this Google Drive Link as mentioned in the readme of the OpenPose repository and put it in
Openpose/modeldirectory. - Extract the driver's pose information for each frame by running
Openpose/openpose.py. This creates theposedirectory with {video_name}.json files for each video.
- Download the body_pose_model.pth and hand_pose_model.pth files from this Google Drive Link as mentioned in the readme of the OpenPose repository and put it in
-
Extract the object features for each frame by running
Preprocessing/yolo_objects.py. This creates theobjectsdirectory with {video_name}.json files for each video. -
Construct the peripheral information for each frame by running
Preprocessing/distances.py -
Get the image embeddings for each frame by running
Preprocessing/image_embeddings.py. This script loads a VGG-16 network whose classifier head is replaced with an 18-way linear layer and fine-tuned on the driver-action classes, expected asmodel.pthin the repository root. Place this fine-tuned checkpoint at the repo root before running. This creates animageEmbeddings.jsonfile inDatasets/annotatedvideosv1/AnnotatedVideos/{video_name}directories for each video. -
Run
Data Preparation/handle_peripheral_inputs.py. This will store the combined peripheral inputs inresults/ALL.json. -
Run
Data Preparation/copy_frames_and_combine_jsons.py. This will store all the combined scene graph and image embeddings inDatasets/annotatedvideosv1/AnnotatedVideos/ALL/frames. -
Run
Data Preparation/split_data.pyto create the train, eval and test split.
Run experiments by running experiment.py. The results will be displayed in the console.
If you find this repository useful in your research, please consider citing the following paper:
@inproceedings{kiD3,
title={Towards Infusing Auxiliary Knowledge for Distracted Driver Detection},
author={Ishwar B Balappanawar and Ashmit Chamoli and Ruwan Wickramarachchi and Aditya Mishra and Ponnurangam Kumaraguru and Amit P. Sheth},
booktitle={KiL'24: Workshop on Knowledge-infused Learning co-located with 30th ACM KDD Conference},
year={2024},
organization={ACM},
url={https://openreview.net/forum?id=WQdNGavZu3}
}