FitzFitzFitz / Road-Object-Detection-Tracking-in-Complex-Environments-Based-on-YOLOv8-DeepSORT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Road Object Detection & Tracking in Complex Environments Based on YOLOv8 & DeepSORT

Abstract

This project focuses on advancing multi-object tracking (MOT) techniques, crucial for autonomous driving and other applications, especially in challenging urban scenes. By enhancing target detection and tracking algorithms, we aim to improve MOT's performance and robustness significantly.

Introduction

Multi-object tracking in complex environments faces numerous challenges. This work reviews existing technologies in MOT, emphasizing target detection algorithms, and proposes improvements. We specifically explore the advancements in YOLOv8, including its network structure, loss function, and data augmentation techniques, and how these enhancements can be leveraged for better detection results.

Methodology

Our approach involves fine-tuning a model based on YOLOv8 tailored to our specific dataset requirements. We also improve the Re-ID model in DeepSORT by adopting a convolutional neural network with a local maximum pooling neural network (LMBN), enhancing feature extraction and target matching. The proposed DeepOC-SORT algorithm combines these advancements with Kalman filtering, observation center re-update, and momentum techniques for increased robustness.

Results

Testing on the MOT17 dataset demonstrated notable improvements: a 4.6% increase in the HOTA index and a 5% overall performance boost. Additionally, the frame rate on test videos rose by 18.7%, exceeding 40 frames per second, meeting real-time video analysis requirements. The algorithm's robustness in adverse conditions, such as rain or densely populated scenes, was also confirmed.

Keywords

Multi-object Tracking, DeepSORT, YOLOv8

Installation

git clone --recurse-submodules https://github.com/mikel-brostrom/yolov8_tracking.git  # clone recursively
cd yolov8_tracking
pip install -r requirements.txt  # install dependencies
Tutorials
Experiments

In inverse chronological order:

Custom object detection architecture

The trackers provided in this repo can be used with other object detectors than Yolov8. Make sure that the output of your detector has the following format:

(x1,y1, x2, y2, obj, cls0, cls1, ..., clsn)

Tracking

$ python track.py --yolo-weights yolov8n.pt     # bboxes only
                                 yolov8n-seg.pt  # bboxes + segmentation masks
Tracking methods
$ python track.py --tracking-method deepocsort
                                    strongsort
                                    ocsort
                                    bytetrack
                                    botsort
Tracking sources

Tracking can be run on most video formats

$ python track.py --source 0                               # webcam
                           img.jpg                         # image
                           vid.mp4                         # video
                           path/                           # directory
                           path/*.jpg                      # glob
                           'https://youtu.be/Zgi9g1ksQHc'  # YouTube
                           'rtsp://example.com/media.mp4'  # RTSP, RTMP, HTTP stream
Select Yolov8 model

There is a clear trade-off between model inference speed and overall performance. In order to make it possible to fulfill your inference speed/accuracy needs you can select a Yolov5 family model for automatic download. These model can be further optimized for you needs by the export.py script

$ python track.py --source 0 --yolo-weights yolov8n.pt --img 640
                                            yolov8s.tflite
                                            yolov8m.pt
                                            yolov8l.onnx 
                                            yolov8x.pt --img 1280
                                            ...
Select ReID model

Some tracking methods combine appearance description and motion in the process of tracking. For those which use appearance, you can choose a ReID model based on your needs from this ReID model zoo. These model can be further optimized for you needs by the reid_export.py script

$ python track.py --source 0 --reid-weights lmbn_n_cuhk03_d.pt
                                            osnet_x0_25_market1501.pt
                                            mobilenetv2_x1_4_msmt17.engine
                                            resnet50_msmt17.onnx
                                            osnet_x1_0_msmt17.pt
                                            ...
Filter tracked classes

By default the tracker tracks all MS COCO classes.

If you want to track a subset of the classes that you model predicts, add their corresponding index after the classes flag,

python track.py --source 0 --yolo-weights yolov8s.pt --classes 16 17  # COCO yolov8 model. Track cats and dogs, only

Here is a list of all the possible objects that a Yolov8 model trained on MS COCO can detect. Notice that the indexing for the classes in this repo starts at zero

Updates with predicted-ahead bbox in StrongSORT

If your use-case contains many occlussions and the motion trajectiories are not too complex, you will most certainly benefit from updating the Kalman Filter by its own predicted state. Select the number of predictions that suits your needs here:

https://github.com/mikel-brostrom/Yolov5_StrongSORT_OSNet/blob/b1da64717ef50e1f60df2f1d51e1ff91d3b31ed4/trackers/strong_sort/configs/strong_sort.yaml#L7

Save the trajectories to you video by:

python track.py --source ... --save-trajectories --save-vid

MOT compliant results

Can be saved to your experiment folder runs/track/<yolo_model>_<deep_sort_model>/ by

python track.py --source ... --save-txt
Tracker hyperparameter tuning

We use a fast and elitist multiobjective genetic algorithm for tracker hyperparameter tuning. By default the objectives are: HOTA, MOTA, IDF1. Run it by

$ python evolve.py --tracking-method strongsort --benchmark MOT17 --n-trials 100  # tune strongsort for MOT17
                   --tracking-method ocsort     --benchmark <your-custom-dataset> --objective HOTA # tune ocsort for maximizing HOTA on your custom tracking dataset

The set of hyperparameters leading to the best HOTA result are written to the tracker's config file.

Contact

For Yolov8 tracking bugs and feature requests please visit https://docs.ultralytics.com/

For other requests please send an email to: fitzfitzfitz.xia@gmail.com

About

License:GNU Affero General Public License v3.0


Languages

Language:Python 96.7%Language:Dockerfile 3.3%