|
| 1 | +简体中文 | [English](README.md) |
| 2 | + |
| 3 | +# CenterTrack (Tracking Objects as Points) |
| 4 | + |
| 5 | +## 内容 |
| 6 | +- [模型库](#模型库) |
| 7 | +- [快速开始](#快速开始) |
| 8 | +- [引用](#引用) |
| 9 | + |
| 10 | +## 模型库 |
| 11 | + |
| 12 | +### MOT17 |
| 13 | + |
| 14 | +| 训练数据集 | 输入尺度 | 总batch_size | val MOTA | test MOTA | FPS | 配置文件 | 下载链接| |
| 15 | +| :---------------: | :-------: | :------------: | :----------------: | :---------: | :-------: | :----: | :-----: | |
| 16 | +| MOT17-half train | 544x960 | 32 | 69.2(MOT17-half) | - | - |[config](./centertrack_dla34_70e_mot17half.yml) | [download](https://paddledet.bj.bcebos.com/models/mot/centertrack_dla34_70e_mot17half.pdparams) | |
| 17 | +| MOT17 train | 544x960 | 32 | 87.9(MOT17-train) | 70.5(MOT17-test) | - |[config](./centertrack_dla34_70e_mot17.yml) | [download](https://paddledet.bj.bcebos.com/models/mot/centertrack_dla34_70e_mot17.pdparams) | |
| 18 | +| MOT17 train(paper) | 544x960| 32 | - | 67.8(MOT17-test) | - | - | - | |
| 19 | + |
| 20 | + |
| 21 | +**注意:** |
| 22 | + - CenterTrack默认使用2 GPUs总batch_size为32进行训练,如改变GPU数或单卡batch_size,最好保持总batch_size为32去训练。 |
| 23 | + - **val MOTA**可能会有1.0 MOTA左右的波动,最好使用2 GPUs和总batch_size为32的默认配置去训练。 |
| 24 | + - **MOT17-half train**是MOT17的train序列(共7个)每个视频的**前一半帧**的图片和标注用作训练集,而用每个视频的后一半帧组成的**MOT17-half val**作为验证集去评估得到**val MOTA**,数据集可以从[此链接](https://bj.bcebos.com/v1/paddledet/data/mot/MOT17.zip)下载,并解压放在`dataset/mot/`文件夹下。 |
| 25 | + - **MOT17 train**是MOT17的train序列(共7个)每个视频的所有帧的图片和标注用作训练集,由于MOT17数据集有限也使用**MOT17 train**数据集去评估得到**val MOTA**,而**test MOTA**为交到[MOT Challenge官网](https://motchallenge.net)评测的结果。 |
| 26 | + |
| 27 | + |
| 28 | +## 快速开始 |
| 29 | + |
| 30 | +### 1.训练 |
| 31 | +通过如下命令一键式启动训练和评估 |
| 32 | +```bash |
| 33 | +# 单卡训练(不推荐) |
| 34 | +CUDA_VISIBLE_DEVICES=0 python tools/train.py -c configs/mot/centertrack/centertrack_dla34_70e_mot17half.yml --amp |
| 35 | +# 多卡训练 |
| 36 | +python -m paddle.distributed.launch --log_dir=centertrack_dla34_70e_mot17half/ --gpus 0,1 tools/train.py -c configs/mot/centertrack/centertrack_dla34_70e_mot17half.yml --amp |
| 37 | +``` |
| 38 | +**注意:** |
| 39 | + - `--eval`暂不支持边训练边验证跟踪的MOTA精度,如果需要开启`--eval`边训练边验证检测mAP,需设置**注释配置文件中的`mot_metric: True`和`metric: MOT`**; |
| 40 | + - `--amp`表示混合精度训练避免显存溢出; |
| 41 | + - CenterTrack默认使用2 GPUs总batch_size为32进行训练,如改变GPU数或单卡batch_size,最好保持总batch_size仍然为32; |
| 42 | + |
| 43 | + |
| 44 | +### 2.评估 |
| 45 | + |
| 46 | +#### 2.1 评估检测效果 |
| 47 | + |
| 48 | +注意首先需要**注释配置文件中的`mot_metric: True`和`metric: MOT`**: |
| 49 | +```python |
| 50 | +### for detection eval.py/infer.py |
| 51 | +mot_metric: False |
| 52 | +metric: COCO |
| 53 | + |
| 54 | +### for MOT eval_mot.py/infer_mot_mot.py |
| 55 | +#mot_metric: True # 默认是不注释的,评估跟踪需要为 True,会覆盖之前的 mot_metric: False |
| 56 | +#metric: MOT # 默认是不注释的,评估跟踪需要使用 MOT,会覆盖之前的 metric: COCO |
| 57 | +``` |
| 58 | + |
| 59 | +然后执行以下语句: |
| 60 | +```bash |
| 61 | +CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c configs/mot/centertrack/centertrack_dla34_70e_mot17half.yml -o weights=output/centertrack_dla34_70e_mot17half/model_final.pdparams |
| 62 | +``` |
| 63 | + |
| 64 | +**注意:** |
| 65 | + - 评估检测使用的是```tools/eval.py```, 评估跟踪使用的是```tools/eval_mot.py```。 |
| 66 | + |
| 67 | +#### 2.2 评估跟踪效果 |
| 68 | + |
| 69 | +注意首先确保设置了**配置文件中的`mot_metric: True`和`metric: MOT`**; |
| 70 | + |
| 71 | +然后执行以下语句: |
| 72 | + |
| 73 | +```bash |
| 74 | +CUDA_VISIBLE_DEVICES=0 python tools/eval_mot.py -c configs/mot/centertrack/centertrack_dla34_70e_mot17half.yml -o weights=output/centertrack_dla34_70e_mot17half/model_final.pdparams |
| 75 | +``` |
| 76 | +**注意:** |
| 77 | + - 评估检测使用的是```tools/eval.py```, 评估跟踪使用的是```tools/eval_mot.py```。 |
| 78 | + - 跟踪结果会存于`{output_dir}/mot_results/`中,里面每个视频序列对应一个txt,每个txt文件每行信息是`frame,id,x1,y1,w,h,score,-1,-1,-1`, 此外`{output_dir}`可通过`--output_dir`设置,默认文件夹名为`output`。 |
| 79 | + |
| 80 | + |
| 81 | +### 3.预测 |
| 82 | + |
| 83 | +#### 3.1 预测检测效果 |
| 84 | +注意首先需要**注释配置文件中的`mot_metric: True`和`metric: MOT`**: |
| 85 | +```python |
| 86 | +### for detection eval.py/infer.py |
| 87 | +mot_metric: False |
| 88 | +metric: COCO |
| 89 | + |
| 90 | +### for MOT eval_mot.py/infer_mot_mot.py |
| 91 | +#mot_metric: True # 默认是不注释的,评估跟踪需要为 True,会覆盖之前的 mot_metric: False |
| 92 | +#metric: MOT # 默认是不注释的,评估跟踪需要使用 MOT,会覆盖之前的 metric: COCO |
| 93 | +``` |
| 94 | + |
| 95 | +然后执行以下语句: |
| 96 | +```bash |
| 97 | +CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/mot/centertrack/centertrack_dla34_70e_mot17half.yml -o weights=output/centertrack_dla34_70e_mot17half/model_final.pdparams --infer_img=demo/000000014439_640x640.jpg --draw_threshold=0.5 |
| 98 | +``` |
| 99 | + |
| 100 | +**注意:** |
| 101 | + - 预测检测使用的是```tools/infer.py```, 预测跟踪使用的是```tools/infer_mot.py```。 |
| 102 | + |
| 103 | + |
| 104 | +#### 3.2 预测跟踪效果 |
| 105 | + |
| 106 | +注意首先确保设置了**配置文件中的`mot_metric: True`和`metric: MOT`**; |
| 107 | + |
| 108 | +然后执行以下语句: |
| 109 | +```bash |
| 110 | +# 下载demo视频 |
| 111 | +wget https://bj.bcebos.com/v1/paddledet/data/mot/demo/mot17_demo.mp4 |
| 112 | +# 预测视频 |
| 113 | +CUDA_VISIBLE_DEVICES=0 python tools/infer_mot.py -c configs/mot/centertrack/centertrack_dla34_70e_mot17half.yml --video_file=mot17_demo.mp4 --draw_threshold=0.5 --save_videos -o weights=output/centertrack_dla34_70e_mot17half/model_final.pdparams |
| 114 | +#或预测图片文件夹 |
| 115 | +CUDA_VISIBLE_DEVICES=0 python tools/infer_mot.py -c configs/mot/centertrack/centertrack_dla34_70e_mot17half.yml --image_dir=mot17_demo/ --draw_threshold=0.5 --save_videos -o weights=output/centertrack_dla34_70e_mot17half/model_final.pdparams |
| 116 | +``` |
| 117 | + |
| 118 | +**注意:** |
| 119 | + - 请先确保已经安装了[ffmpeg](https://ffmpeg.org/ffmpeg.html), Linux(Ubuntu)平台可以直接用以下命令安装:`apt-get update && apt-get install -y ffmpeg`。 |
| 120 | + - `--save_videos`表示保存可视化视频,同时会保存可视化的图片在`{output_dir}/mot_outputs/`中,`{output_dir}`可通过`--output_dir`设置,默认文件夹名为`output`。 |
| 121 | + |
| 122 | + |
| 123 | +### 4. 导出预测模型 |
| 124 | + |
| 125 | +注意首先确保设置了**配置文件中的`mot_metric: True`和`metric: MOT`**; |
| 126 | + |
| 127 | +```bash |
| 128 | +CUDA_VISIBLE_DEVICES=0 python tools/export_model.py -c configs/mot/centertrack/centertrack_dla34_70e_mot17half.yml -o weights=https://paddledet.bj.bcebos.com/models/mot/centertrack_dla34_70e_mot17half.pdparams |
| 129 | +``` |
| 130 | + |
| 131 | +### 5. 用导出的模型基于Python去预测 |
| 132 | + |
| 133 | +注意首先应在`deploy/python/tracker_config.yml`中设置`type: CenterTracker`。 |
| 134 | + |
| 135 | +```bash |
| 136 | +# 预测某个视频 |
| 137 | +# wget https://bj.bcebos.com/v1/paddledet/data/mot/demo/mot17_demo.mp4 |
| 138 | +python deploy/python/mot_centertrack_infer.py --model_dir=output_inference/centertrack_dla34_70e_mot17half/ --tracker_config=deploy/python/tracker_config.yml --video_file=mot17_demo.mp4 --device=GPU --save_images=True --save_mot_txts |
| 139 | +# 预测图片文件夹 |
| 140 | +python deploy/python/mot_centertrack_infer.py --model_dir=output_inference/centertrack_dla34_70e_mot17half/ --tracker_config=deploy/python/tracker_config.yml --image_dir=mot17_demo/ --device=GPU --save_images=True --save_mot_txts |
| 141 | +``` |
| 142 | + |
| 143 | +**注意:** |
| 144 | + - 跟踪模型是对视频进行预测,不支持单张图的预测,默认保存跟踪结果可视化后的视频,可添加`--save_mot_txts`(对每个视频保存一个txt)或`--save_mot_txt_per_img`(对每张图片保存一个txt)表示保存跟踪结果的txt文件,或`--save_images`表示保存跟踪结果可视化图片。 |
| 145 | + - 跟踪结果txt文件每行信息是`frame,id,x1,y1,w,h,score,-1,-1,-1`。 |
| 146 | + |
| 147 | + |
| 148 | +## 引用 |
| 149 | +``` |
| 150 | +@article{zhou2020tracking, |
| 151 | + title={Tracking Objects as Points}, |
| 152 | + author={Zhou, Xingyi and Koltun, Vladlen and Kr{\"a}henb{\"u}hl, Philipp}, |
| 153 | + journal={ECCV}, |
| 154 | + year={2020} |
| 155 | +} |
| 156 | +``` |
0 commit comments