Home

Awesome

Threat Detection and Unattended Baggage Detection with Associated Person Tracking

YOLOv8s + OpenVINO + DeepSORT: A demo of threat detection and unattended baggage tracking.

A YOLOv8s is trained on COCO dataset and the weights are converted to OpenVINO format. The model is then used to detect threats and unattended baggage in a video stream. The detections are then tracked using DeepSORT.

Features

Please note: The system's accuracy and effectiveness depend on the quality of the object detection model, the configuration of thresholds and durations, and the clarity of the video feed.

Current limitations in this demo:

How can it be improved:

Since the complexity of testing the whole implementation, I won't be able to patch all issues before the Intel Chips' CHallenge - Detect Faster deadline.

How it works

  1. The model is trained on COCO dataset using YOLOv8s. (We used the s instead of n because we were having trouble with keeping consistency across the frames)
  2. The model is then converted to OpenVINO format using the convert.ipynb notebook.
  3. The model is then used to detect threats and unattended baggage in a video stream:
    • Filter detections to only show the threats and persons and unattended baggage.
    • Create unique detections for each person and unattended baggage using DeepSORT.
    • Then create pairs for them, while also returning the alerts for threats.
    • Create a relationship between the unattended baggage and the closest person to track the unattended baggage.
    • Finally, draw the detections, keep track of the time period of the unattended baggage and draw the alerts.

File Structure

  1. demo.ipynb is the main file that runs the inference, you have specified the video source and OpenVINO optimised model path. You may also play with the DeepSORT and Threat alert configuration in there.
  2. convert.ipynb is copied straight from YOLOv8-OpenVINO-Optimised used purely to optimise the YOLO model using OpenVINO Toolkit.
  3. utils.py contains a ton of helper functions and methods used for post-processing on the image. To be specific:
    • log_output Outputs logging stuff to log.txt
    • VideoPlayer class handles the counting of fps and management of frames (Copied from OpenVINO Notebooks - YOLO optimization)
    • plot_one_box plots a single box in the given frame (Copied from OpenVINO Notebooks - YOLO optimization)
    • letterbox resizes the image to fit into a new shape by saving the original aspect ratio and pads it to meet stride-multiple constraints (Copied from OpenVINO Notebooks - YOLO optimization)
    • postprocess applies non maximum suppression algorithm to detections and rescale boxes to their original image size (Copied from OpenVINO Notebooks - YOLO optimization)
    • process_results manages the filtering and DeepSORT tracking for the objects.
    • track_risk manages the alerts and tracking of object pairs

How to run

  1. Install the requirements:
    pip install -r requirements.txt
    
  2. Create the optimized model by running the notebook cells at convert.ipynb to convert the model to OpenVINO format. (IMPORTANT)
  3. Run the cell at demo.ipynb to run the demo. (Make sure to change the video path to your supported video source)

Note: Demo won't work without creating the optimized model.

Huge thanks to:

Demo (CPU)

Unattended Baggage Detection: demo1 demo2

Thread Detection: demo1

More Demos: demo1 demo1 demo1