使用该项目要求paddle版本>=2.2.2,输入以下命令查看paddle版本:
import paddle
print(paddle.__version__)
我的paddle版本为2.1.1,因此需要卸载重装为2,2,2版本:
我这里选择CUDA11.0对应的paddle版本:
python -m pip install paddlepaddle-gpu==2.2.2.post110 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html
其他依赖环境:
tqdm
typeguard ; python_version >= '3.4'
visualdl>=2.1.0 ; python_version <= '3.7'
opencv-python
PyYAML
shapely
scipy
terminaltables
Cython
pycocotools
#xtcocotools==1.6 #only for crowdpose
setuptools>=42.0.0
lap
sklearn
motmetrics
openpyxl
cython_bbox
直接:
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
需要使用Develop分支,这个功能多:
git clone https://gitee.com/paddlepaddle/PaddleDetection.git -b develop
导出JDE YOLOv3检测器模型;
# 导出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
导出PCB Pyramid 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
使用导出的JDE YOLOv3+PCB Pyramid ReID加载单镜头MOT任务:
# 用导出JDE YOLOv3行人检测模型和PCB Pyramid ReID模型
python deploy/pptracking/python/mot_sde_infer.py --model_dir=output_inference/jde_yolov3_darknet53_30e_1088x608_mix/ --tracker_config=./deploy/pptracking/python/tracker_config.yml --reid_model_dir=output_inference/deepsort_pcb_pyramid_r101/ --video_file=test.mp4 --device=GPU --save_mot_txts
旧版:
# 用导出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=test.mp4 --device=GPU --save_mot_txts
检测效果如下,框的并不准,后来发现是paddle版本和PaddleDetection版本没有满足上面的条件导致的数值偏差:
行人跨镜头
python deploy/pptracking/python/mot_sde_infer.py --model_dir=output_inference/jde_yolov3_darknet53_30e_1088x608_mix/ --tracker_config=./deploy/pptracking/python/tracker_config.yml --reid_model_dir=output_inference/deepsort_pcb_pyramid_r101/ --mtmct_dir=mtmct-demo --mtmct_cfg=deploy/pptracking/python/mtmct_cfg.yml --device=GPU --scaled=True --save_mot_txts --save_images
旧版跨镜头:
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/ --mtmct_dir=mtmct-demo --mtmct_cfg=deploy/pptracking/python/mtmct_cfg.yml --device=GPU --scaled=True --save_mot_txts --save_images
导出PPyolov2检测器模型;
# 或导出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
导出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
使用导出的PPyolov2+PPLCNet ReID加载单镜头MOT任务:
python deploy/pptracking/python/mot_sde_infer.py --model_dir=output_inference/ppyolov2_r50vd_dcn_365e_640x640_mot17half/ --tracker_config=./deploy/pptracking/python/tracker_config.yml --reid_model_dir=output_inference/deepsort_pplcnet/ --video_file=test.mp4 --device=GPU --scaled=True --save_mot_txts
旧版:
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=test.mp4 --device=GPU --scaled=True --save_mot_txts
python deploy/pptracking/python/mot_sde_infer.py --model_dir=output_inference/ppyolov2_r50vd_dcn_365e_640x640_mot17half/ --tracker_config=./deploy/pptracking/python/tracker_config.yml --reid_model_dir=output_inference/deepsort_pplcnet/ --mtmct_dir=mtmct-demo --mtmct_cfg=deploy/pptracking/python/mtmct_cfg.yml --device=GPU --scaled=True --save_mot_txts --save_images
旧版跨镜头:
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/ --mtmct_dir=mtmct-demo --mtmct_cfg=deploy/pptracking/python/mtmct_cfg.yml --device=GPU --scaled=True --save_mot_txts --save_images
下载demo视频:
wget https://paddledet.bj.bcebos.com/data/mot/demo/mtmct-demo.tar
tar -xvf mtmct-demo.tar
下载ppyolov2检测器模型:
wget https://paddledet.bj.bcebos.com/models/mot/deepsort/ppyolov2_r50vd_dcn_365e_aic21mtmct_vehicle.tar
tar -xvf ppyolov2_r50vd_dcn_365e_aic21mtmct_vehicle.tar
下载REID模型:
wget https://paddledet.bj.bcebos.com/models/mot/deepsort/deepsort_pplcnet_vehicle.tar
tar -xvf deepsort_pplcnet_vehicle.tar
使用导出的两个模型加载单镜头MOT任务:
# 用导出的ppyolov2车辆检测模型和PPLCNet车辆ReID模型去基于Python预测
python deploy/pptracking/python/mot_sde_infer.py --model_dir=output_inference/ppyolov2_r50vd_dcn_365e_aic21mtmct_vehicle/ --tracker_config=./deploy/pptracking/python/tracker_config.yml --reid_model_dir=output_inference/deepsort_pplcnet_vehicle/ --video_file=c003.mp4 --device=GPU --threshold=0.5 --scaled=True --save_mot_txts
车辆跨镜头:
新版:
# 用导出的PicoDet车辆检测模型和PPLCNet车辆ReID模型去基于Python预测
python deploy/pptracking/python/mot_sde_infer.py --model_dir=output_inference/ppyolov2_r50vd_dcn_365e_aic21mtmct_vehicle/ --tracker_config=./deploy/pptracking/python/tracker_config.yml --reid_model_dir=output_inference/deepsort_pplcnet_vehicle/ --mtmct_dir=mtmct-demo --mtmct_cfg=deploy/pptracking/python/mtmct_cfg.yml --device=GPU --scaled=True --save_mot_txts --save_images
旧版(没有任何问题):
python deploy/pptracking/python/mot_sde_infer.py --model_dir=output_inference/ppyolov2_r50vd_dcn_365e_aic21mtmct_vehicle/ --reid_model_dir=output_inference/deepsort_pplcnet_vehicle/ --mtmct_dir=mtmct-demo --mtmct_cfg=deploy/pptracking/python/mtmct_cfg.yml --device=GPU --scaled=True --save_mot_txts --save_images