简体中文 | English
DeepSORT(Deep Cosine Metric Learning SORT) 扩展了原有的SORT(Simple Online and Realtime Tracking)算法,增加了一个CNN模型用于在检测器限定的人体部分图像中提取特征,在深度外观描述的基础上整合外观信息,将检出的目标分配和更新到已有的对应轨迹上即进行一个ReID重识别任务。DeepSORT所需的检测框可以由任意一个检测器来生成,然后读入保存的检测结果和视频图片即可进行跟踪预测。ReID模型此处选择PaddleClas提供的PCB+Pyramid ResNet101
和PPLCNet
模型。
骨干网络 | 输入尺寸 | MOTA | IDF1 | IDS | FP | FN | FPS | 检测结果或模型 | ReID模型 | 配置文件 |
---|---|---|---|---|---|---|---|---|---|---|
ResNet-101 | 1088x608 | 72.2 | 60.5 | 998 | 8054 | 21644 | - | 检测结果 | ReID模型 | 配置文件 |
ResNet-101 | 1088x608 | 68.3 | 56.5 | 1722 | 17337 | 15890 | - | 检测模型 | ReID模型 | 配置文件 |
PPLCNet | 1088x608 | 72.2 | 59.5 | 1087 | 8034 | 21481 | - | 检测结果 | ReID模型 | 配置文件 |
PPLCNet | 1088x608 | 68.1 | 53.6 | 1979 | 17446 | 15766 | - | 检测模型 | ReID模型 | 配置文件 |
骨干网络 | 输入尺寸 | MOTA | IDF1 | IDS | FP | FN | FPS | 检测结果或模型 | ReID模型 | 配置文件 |
---|---|---|---|---|---|---|---|---|---|---|
ResNet-101 | 1088x608 | 64.1 | 53.0 | 1024 | 12457 | 51919 | - | 检测结果 | ReID模型 | 配置文件 |
ResNet-101 | 1088x608 | 61.2 | 48.5 | 1799 | 25796 | 43232 | - | 检测模型 | ReID模型 | 配置文件 |
PPLCNet | 1088x608 | 64.0 | 51.3 | 1208 | 12697 | 51784 | - | 检测结果 | ReID模型 | 配置文件 |
PPLCNet | 1088x608 | 61.1 | 48.8 | 2010 | 25401 | 43432 | - | 检测模型 | ReID模型 | 配置文件 |
检测训练数据集 | 检测器 | ReID | 检测mAP | MOTA | IDF1 | FPS | 配置文件 |
---|---|---|---|---|---|---|---|
MIX | JDE YOLOv3 | PCB Pyramid | - | 66.9 | 62.7 | - | 配置文件 |
MIX | JDE YOLOv3 | PPLCNet | - | 66.3 | 62.1 | - | 配置文件 |
MOT-17 half train | YOLOv3 | PPLCNet | 42.7 | 50.2 | 52.4 | - | 配置文件 |
MOT-17 half train | PPYOLOv2 | PPLCNet | 46.8 | 51.8 | 55.8 | - | 配置文件 |
MOT-17 half train | PPYOLOe | PPLCNet | 52.9 | 56.7 | 60.5 | - | 配置文件 |
MOT-17 half train | PPYOLOe | ResNet-50 | 52.9 | 56.7 | 64.6 | - | 配置文件 |
注意:
模型权重下载链接在配置文件中的det_weights
和reid_weights
,运行验证的命令即可自动下载。
DeepSORT是分离检测器和ReID模型的,其中检测器单独训练MOT数据集,而组装成DeepSORT后只用于评估,现在支持两种评估的方式。
det_results_dir
|——————MOT16-02.txt
|——————MOT16-04.txt
|——————MOT16-05.txt
|——————MOT16-09.txt
|——————MOT16-10.txt
|——————MOT16-11.txt
|——————MOT16-13.txt
对于MOT16数据集,可以下载PaddleDetection提供的一个经过匹配之后的检测框结果det_results_dir.zip并解压:
wget https://dataset.bj.bcebos.com/mot/det_results_dir.zip
如果使用更强的检测模型,可以取得更好的结果。其中每个txt是每个视频中所有图片的检测结果,每行都描述一个边界框,格式如下:
[frame_id],[x0],[y0],[w],[h],[score],[class_id]
frame_id
是图片帧的序号
x0,y0
是目标框的左上角x和y坐标
w,h
是目标框的像素宽高
score
是目标框的得分
class_id
是目标框的类别,如果只有1类则是0
方式2:同时加载检测模型和ReID模型,此处选用JDE版本的YOLOv3,具体配置见configs/mot/deepsort/deepsort_jde_yolov3_pcb_pyramid.yml
。加载其他通用检测模型可参照configs/mot/deepsort/deepsort_ppyolov2_pplcnet.yml
进行修改。
CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c configs/mot/deepsort/detector/ppyoloe_crn_l_36e_640x640_mot17half.yml
注意:
tools/eval.py
, 评估跟踪使用的是tools/eval_mot.py
。方式1:加载检测结果文件和ReID模型,得到跟踪结果
CUDA_VISIBLE_DEVICES=0 python tools/eval_mot.py -c configs/mot/deepsort/reid/deepsort_pcb_pyramid_r101.yml --det_results_dir {your detection results}
# 或者
CUDA_VISIBLE_DEVICES=0 python tools/eval_mot.py -c configs/mot/deepsort/reid/deepsort_pplcnet.yml --det_results_dir {your detection results}
方式2:加载行人检测模型和ReID模型,得到跟踪结果
CUDA_VISIBLE_DEVICES=0 python tools/eval_mot.py -c configs/mot/deepsort/deepsort_jde_yolov3_pcb_pyramid.yml
# 或者
CUDA_VISIBLE_DEVICES=0 python tools/eval_mot.py -c configs/mot/deepsort/deepsort_jde_yolov3_pplcnet.yml
# 或者
CUDA_VISIBLE_DEVICES=0 python tools/eval_mot.py -c configs/mot/deepsort/deepsort_ppyolov2_pplcnet.yml --scaled=True
# 或者
CUDA_VISIBLE_DEVICES=0 python tools/eval_mot.py -c configs/mot/deepsort/deepsort_ppyoloe_resnet.yml --scaled=True
注意:
--scaled
表示在模型输出结果的坐标是否已经是缩放回原图的,如果使用的检测模型是JDE YOLOv3则为False,如果使用通用检测模型则为True, 默认值是False。{output_dir}/mot_results/
中,里面每个视频序列对应一个txt,每个txt文件每行信息是frame,id,x1,y1,w,h,score,-1,-1,-1
, 此外{output_dir}
可通过--output_dir
设置。使用单个GPU通过如下命令预测一个视频,并保存为视频
# 加载JDE YOLOv3行人检测模型和PCB Pyramid ReID模型,并保存为视频
CUDA_VISIBLE_DEVICES=0 python tools/infer_mot.py -c configs/mot/deepsort/deepsort_jde_yolov3_pcb_pyramid.yml --video_file={your video name}.mp4 --save_videos
# 或者加载PPYOLOv2行人检测模型和PPLCNet ReID模型,并保存为视频
CUDA_VISIBLE_DEVICES=0 python tools/infer_mot.py -c configs/mot/deepsort/deepsort_ppyolov2_pplcnet.yml --video_file={your video name}.mp4 --scaled=True --save_videos
注意:
apt-get update && apt-get install -y ffmpeg
。--scaled
表示在模型输出结果的坐标是否已经是缩放回原图的,如果使用的检测模型是JDE的YOLOv3则为False,如果使用通用检测模型则为True。Step 1:导出检测模型
# 导出JDE YOLOv3行人检测模型
CUDA_VISIBLE_DEVICES=0 python tools/export_model.py -c configs/mot/deepsort/detector/jde_yolov3_darknet53_30e_1088x608_mix.yml -o weights=https://paddledet.bj.bcebos.com/models/mot/deepsort/jde_yolov3_darknet53_30e_1088x608_mix.pdparams
# 或导出PPYOLOv2行人检测模型
CUDA_VISIBLE_DEVICES=0 python tools/export_model.py -c configs/mot/deepsort/detector/ppyolov2_r50vd_dcn_365e_640x640_mot17half.yml -o weights=https://paddledet.bj.bcebos.com/models/mot/deepsort/ppyolov2_r50vd_dcn_365e_640x640_mot17half.pdparams
Step 2:导出ReID模型
# 导出PCB Pyramid ReID模型
CUDA_VISIBLE_DEVICES=0 python tools/export_model.py -c configs/mot/deepsort/reid/deepsort_pcb_pyramid_r101.yml -o reid_weights=https://paddledet.bj.bcebos.com/models/mot/deepsort/deepsort_pcb_pyramid_r101.pdparams
# 或者导出PPLCNet ReID模型
CUDA_VISIBLE_DEVICES=0 python tools/export_model.py -c configs/mot/deepsort/reid/deepsort_pplcnet.yml -o reid_weights=https://paddledet.bj.bcebos.com/models/mot/deepsort/deepsort_pplcnet.pdparams
# 用导出JDE YOLOv3行人检测模型和PCB Pyramid ReID模型
python deploy/pptracking/python/mot_sde_infer.py --model_dir=output_inference/jde_yolov3_darknet53_30e_1088x608_mix/ --reid_model_dir=output_inference/deepsort_pcb_pyramid_r101/ --video_file={your video name}.mp4 --device=GPU --save_mot_txts
# 或用导出的PPYOLOv2行人检测模型和PPLCNet ReID模型
python deploy/pptracking/python/mot_sde_infer.py --model_dir=output_inference/ppyolov2_r50vd_dcn_365e_640x640_mot17half/ --reid_model_dir=output_inference/deepsort_pplcnet/ --video_file={your video name}.mp4 --device=GPU --scaled=True --save_mot_txts
注意:
--save_mot_txts
(对每个视频保存一个txt)或--save_mot_txt_per_img
(对每张图片保存一个txt)表示保存跟踪结果的txt文件,或--save_images
表示保存跟踪结果可视化图片。frame,id,x1,y1,w,h,score,-1,-1,-1
。--scaled
表示在模型输出结果的坐标是否已经是缩放回原图的,如果使用的检测模型是JDE的YOLOv3则为False,如果使用通用检测模型则为True。detector/xxx.yml
是纯粹的检测模型配置文件,如detector/ppyolov2_r50vd_dcn_365e_640x640_mot17half.yml
,支持检测的所有流程(train/eval/infer/export/deploy)。DeepSORT跟踪的eval/infer与这个纯检测的yml文件无关,但是export的时候需要这个纯检测的yml单独导出检测模型,DeepSORT跟踪导出模型是分开detector和reid分别导出的,用户可自行定义和组装detector+reid成为一个完整的DeepSORT跟踪系统。detector/
下的检测器配置文件中,用户需要将自己的数据集转为COCO格式。由于ID的真实标签不需要参与进去,用户可以在此自行配置任何检测模型,只需保证输出结果包含结果框的种类、坐标和分数即可。reid/deepsort_yyy.yml
文件夹里的是ReID模型和tracker的配置文件,如reid/deepsort_pplcnet.yml
,此处ReID模型是由PaddleClas提供的deepsort_pcb_pyramid_r101.yml
和deepsort_pplcnet.yml
,是在Market1501(751类人)行人ReID数据集上训练得到的,训练细节待PaddleClas公布。deepsort_xxx_yyy.yml
是一个完整的DeepSORT跟踪的配置,如deepsort_ppyolov2_pplcnet.yml
,其中检测部分xxx
是detector/
里的,reid和tracker部分yyy
是reid/
里的。reid/deepsort_yyy.yml
加载检测结果文件和yyy
ReID模型,方式2是使用deepsort_xxx_yyy.yml
加载xxx
检测模型和yyy
ReID模型,但是DeepSORT跟踪的deploy必须使用deepsort_xxx_yyy.yml
。detector/xxx.yml
,ReID一般不单独使用,如需单独使用必须提前加载检测结果文件然后只使用reid/deepsort_yyy.yml
。1.先将数据集制作成COCO格式按通用检测模型配置来训练,参照detector/
文件夹里的模型配置文件,制作生成detector/xxx.yml
, 已经支持有Faster R-CNN、YOLOv3、PPYOLOv2、JDE YOLOv3和PicoDet等模型。
2.制作deepsort_xxx_yyy.yml
, 其中DeepSORT.detector
的配置就是detector/xxx.yml
里的, EvalMOTDataset
和det_weights
可以自行设置。yyy
是reid/deepsort_yyy.yml
如reid/deepsort_pplcnet.yml
。
CUDA_VISIBLE_DEVICES=0 python tools/eval_mot.py -c configs/mot/deepsort/deepsort_xxx_yyy.yml --scaled=True
CUDA_VISIBLE_DEVICES=0 python tools/infer_mot.py -c configs/mot/deepsort/deepsort_xxx_yyy.yml --video_file={your video name}.mp4 --scaled=True --save_videos
# 导出检测模型
CUDA_VISIBLE_DEVICES=0 python tools/export_model.py -c configs/mot/deepsort/detector/xxx.yml
# 导出ReID模型
CUDA_VISIBLE_DEVICES=0 python tools/export_model.py -c configs/mot/deepsort/reid/deepsort_yyy.yml
python deploy/pptracking/python/mot_sde_infer.py --model_dir=output_inference/xxx./ --reid_model_dir=output_inference/deepsort_yyy/ --video_file={your video name}.mp4 --device=GPU --scaled=True --save_mot_txts
注意:
--scaled
表示在模型输出结果的坐标是否已经是缩放回原图的,如果使用的检测模型是JDE的YOLOv3则为False,如果使用通用检测模型则为True。@inproceedings{Wojke2017simple,
title={Simple Online and Realtime Tracking with a Deep Association Metric},
author={Wojke, Nicolai and Bewley, Alex and Paulus, Dietrich},
booktitle={2017 IEEE International Conference on Image Processing (ICIP)},
year={2017},
pages={3645--3649},
organization={IEEE},
doi={10.1109/ICIP.2017.8296962}
}
@inproceedings{Wojke2018deep,
title={Deep Cosine Metric Learning for Person Re-identification},
author={Wojke, Nicolai and Bewley, Alex},
booktitle={2018 IEEE Winter Conference on Applications of Computer Vision (WACV)},
year={2018},
pages={748--756},
organization={IEEE},
doi={10.1109/WACV.2018.00087}
}
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》