最近做了一个小工作, 想着把几种多目标跟踪的tracker用统一的步骤和代码风格写一下, 就以YOLO v7作为检测器, 集成了SORT, DeepSORT, ByteTrack, BoT-SORT, DeepMOT五种tracker. 在VisDrone2019-MOT数据集上训练并测试.
如果对您有用, 欢迎star!!!
Tracker | MOTA | IDF1 | IDS | fps |
---|---|---|---|---|
SORT | 26.4 | 36.4 | 3264 | 12.2 |
DeepSORT | 12.1 | 26.9 | 3860 | 12.4 |
ByteTrack | 25.1 | 40.8 | 1590 | 14.32 |
DeepMOT | 15.0 | 24.8 | 3666 | 7.64 |
BoT-SORT | 23.0 | 41.4 | 1014 | 5.41 |
SORT,
DeepSORT,
ByteTrack(ECCV2022),
DeepMOT(CVPR2020),
BoT-SORT(arxiv2206),
在VisDrone2019-MOT train训练约10 epochs, 采用YOLO v7 w6结构, COCO预训练模型基础上训练. GPU: single Tesla A100, 每个epoch约40min.
在VisDrone2019-MOT test dev测试, 跟踪所有的类别.
Tracker | MOTA | IDF1 | IDS | fps |
---|---|---|---|---|
SORT | 26.4 | 36.4 | 3264 | 12.2 |
DeepSORT | 12.1 | 26.9 | 3860 | 12.4 |
ByteTrack | 25.1 | 40.8 | 1590 | 14.32 |
DeepMOT | 15.0 | 24.8 | 3666 | 7.64 |
BoT-SORT | 23.0 | 41.4 | 1014 | 5.41 |
fps具有一定的随机性
\space
\space
pip install motmetrics
)pip install cython_bbox
)训练遵循YOLO v7的训练方式, 数据集格式可以参照YOLO v5 train custom data
即数据集文件遵循
class x_center y_center width height
其中x_center y_center width height必须是归一化的.
如果您训练VisDrone数据集, 可以直接调用:
python tools/convert_VisDrone_to_yolov2.py --split_name VisDrone2019-MOT-train --generate_imgs
需要您修改一些路径变量.
准备好数据集后, 假如训练YOLO v7-w6模型(single GPU):
python train_aux.py --dataset visdrone --workers 8 --device <$GPU_id$> --batch-size 16 --data data/visdrone_all.yaml --img 1280 1280 --cfg cfg/training/yolov7-w6.yaml --weights <$YOLO v7 pretrained model path$> --name yolov7-w6-custom --hyp data/hyp.scratch.custom.yaml
更多训练信息参考YOLO v7
model_path 参数为训练后的detector model, 假设路径为 runs/train/yolov7-w6-custom4/weights/best.pt
SORT :
python tracker/track.py --dataset visdrone --data_format origin --tracker sort --model_path runs/train/yolov7-w6-custom4/weights/best.pt
DeepSORT:
python tracker/track.py --dataset visdrone --data_format origin --tracker deepsort --model_path runs/train/yolov7-w6-custom4/weights/best.pt
ByteTrack:
python tracker/track.py --dataset visdrone --data_format origin --tracker bytetrack --model_path runs/train/yolov7-w6-custom4/weights/best.pt
DeepMOT:
python tracker/track.py --dataset visdrone --data_format origin --tracker deepmot --model_path runs/train/yolov7-w6-custom4/weights/best.pt
BoT-SORT:
python tracker/track.py --dataset visdrone --data_format origin --tracker botsort --model_path runs/train/yolov7-w6-custom4/weights/best.pt
您也可以通过增加
--save_images --save_videos
来控制保存跟踪结果的图片与视频.
只需保证detector的输出格式为
(batch_size, num_objects, x_center, y_center, width, height, obj_conf, category)
或经典的yolo格式
(batch_size, num_objects, x_center, y_center, width, height, obj_conf, category_conf0, category_conf1, category_conf2, ...)
注意: 推理的时候batch_size要求为1.