From e25bbc74a88de614cbb781a896ba821e794dd145 Mon Sep 17 00:00:00 2001 From: Feng Ni Date: Fri, 24 Jun 2022 11:49:04 +0800 Subject: [PATCH] [MOT] fix bytetrack yolox modelzoo doc (#6262) * fix bytetrack_yolox modelzoo doc, test=document_fix * add mot16test leaderboard, test=document_fix --- configs/mot/bytetrack/README_cn.md | 40 +++++++--- configs/mot/bytetrack/_base_/mix_mot_ch.yml | 34 ++++++++ .../mot/bytetrack/bytetrack_yolox_ht21.yml | 8 +- configs/mot/bytetrack/detector/README_cn.md | 11 ++- .../yolox_x_24e_800x1440_mix_mot_ch.yml | 80 +++++++++++++++++++ configs/mot/headtracking21/README_cn.md | 2 +- ppdet/engine/tracker.py | 9 ++- 7 files changed, 163 insertions(+), 21 deletions(-) create mode 100644 configs/mot/bytetrack/_base_/mix_mot_ch.yml create mode 100644 configs/mot/bytetrack/detector/yolox_x_24e_800x1440_mix_mot_ch.yml diff --git a/configs/mot/bytetrack/README_cn.md b/configs/mot/bytetrack/README_cn.md index 7620366da..1313dfc71 100644 --- a/configs/mot/bytetrack/README_cn.md +++ b/configs/mot/bytetrack/README_cn.md @@ -13,21 +13,39 @@ ## 模型库 -### ByteTrack在MOT-17 half Val Set上结果 +### 基于不同检测器的ByteTrack在MOT-17 half Val Set上结果 -| 检测训练数据集 | 检测器 | 输入尺度 | ReID | 检测mAP | MOTA | IDF1 | FPS | 配置文件 | +| 检测训练数据集 | 检测器 | 输入尺度 | ReID | 检测mAP(0.5:0.95) | MOTA | IDF1 | FPS | 配置文件 | | :-------- | :----- | :----: | :----:|:------: | :----: |:-----: |:----:|:----: | -| MOT-17 half train | YOLOv3 | 608x608 | - | 42.7 | 49.3 | 55.5 | - |[配置文件](./bytetrack_yolov3.yml) | -| MOT-17 half train | PPYOLOe | 640x640 | - | 52.7 | 50.4 | 59.7 | - |[配置文件](./bytetrack_ppyoloe.yml) | -| MOT-17 half train | PPYOLOe | 640x640 |PPLCNet| 52.7 | 51.7 | 58.8 | - |[配置文件](./bytetrack_ppyoloe_pplcnet.yml) | -| mix_det | YOLOX-x | 800x1440| - | 61.9 | 77.3 | 71.6 | - |[配置文件](./bytetrack_yolox.yml) | +| MOT-17 half train | YOLOv3 | 608x608 | - | 42.7 | 49.5 | 54.8 | - |[配置文件](./bytetrack_yolov3.yml) | +| MOT-17 half train | PP-YOLOE-l | 640x640 | - | 52.9 | 50.4 | 59.7 | - |[配置文件](./bytetrack_ppyoloe.yml) | +| MOT-17 half train | PP-YOLOE-l | 640x640 |PPLCNet| 52.9 | 51.7 | 58.8 | - |[配置文件](./bytetrack_ppyoloe_pplcnet.yml) | +| **mot17_ch** | YOLOX-x | 800x1440| - | 61.9 | 77.3 | 71.6 | - |[配置文件](./bytetrack_yolox.yml) | +| **mix_det** | YOLOX-x | 800x1440| - | 65.4 | 84.5 | 77.4 | - |[配置文件](./bytetrack_yolox.yml) | + + +**注意:** + - 检测任务相关配置和文档请查看[detector](detector/) + + +### YOLOX-x ByteTrack(mix_det) + +[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/pp-yoloe-an-evolved-version-of-yolo/multi-object-tracking-on-mot16)](https://paperswithcode.com/sota/multi-object-tracking-on-mot16?p=pp-yoloe-an-evolved-version-of-yolo) + +| 网络 | 测试集 | MOTA | IDF1 | IDS | FP | FN | FPS | 下载链接 | 配置文件 | +| :---------: | :-------: | :----: | :----: | :----: | :----: | :----: | :------: | :----: |:-----: | +| ByteTrack-x| MOT-17 Train | 84.4 | 72.8 | 837 | 5653 | 10985 | - |[下载链接](https://paddledet.bj.bcebos.com/models/mot/yolox_x_24e_800x1440_mix_det.pdparams) | [配置文件](./bytetrack_yolox.yml) | +| ByteTrack-x| MOT-17 Test | 78.4 | 69.7 | 4974 | 37551 | 79524 | - |[下载链接](https://paddledet.bj.bcebos.com/models/mot/yolox_x_24e_800x1440_mix_det.pdparams) | [配置文件](./bytetrack_yolox.yml) | +| ByteTrack-x| MOT-16 Train | 83.5 | 72.7 | 800 | 6973 | 10419 | - |[下载链接](https://paddledet.bj.bcebos.com/models/mot/yolox_x_24e_800x1440_mix_det.pdparams) | [配置文件](./bytetrack_yolox.yml) | +| ByteTrack-x| MOT-16 Test | 77.7 | 70.1 | 1570 | 15695 | 23304 | - |[下载链接](https://paddledet.bj.bcebos.com/models/mot/yolox_x_24e_800x1440_mix_det.pdparams) | [配置文件](./bytetrack_yolox.yml) | + **注意:** -- 模型权重下载链接在配置文件中的```det_weights```和```reid_weights```,运行```tools/eval_mot.py```评估的命令即可自动下载。 -- **MOT17-half train**是MOT17的train序列(共7个)每个视频的前一半帧的图片和标注组成的数据集,而为了验证精度可以都用**MOT17-half val**数据集去评估,它是每个视频的后一半帧组成的,数据集可以从[此链接](https://dataset.bj.bcebos.com/mot/MOT17.zip)下载,并解压放在`dataset/mot/`文件夹下。 -- **mix_det**是MOT17、crowdhuman、Cityscapes、ETHZ组成的联合数据集,数据集整理的格式和目录可以参考[此链接](https://github.com/ifzhang/ByteTrack#data-preparation),最终放置于`dataset/mot/`目录下。为了验证精度可以都用**MOT17-half val**数据集去评估。 -- ByteTrack的训练是单独的检测器训练MOT数据集,推理是组装跟踪器去评估MOT指标,单独的检测模型也可以评估检测指标。 -- ByteTrack的导出部署,是单独导出检测模型,再组装跟踪器运行的,参照[PP-Tracking](../../../deploy/pptracking/python/README.md)。 + - 模型权重下载链接在配置文件中的```det_weights```和```reid_weights```,运行```tools/eval_mot.py```评估的命令即可自动下载,```reid_weights```若为None则表示不需要使用,ByteTrack默认不使用ReID权重。 + - **MOT17-half train**是MOT17的train序列(共7个)每个视频的前一半帧的图片和标注组成的数据集,而为了验证精度可以都用**MOT17-half val**数据集去评估,它是每个视频的后一半帧组成的,数据集可以从[此链接](https://dataset.bj.bcebos.com/mot/MOT17.zip)下载,并解压放在`dataset/mot/`文件夹下。 + - **mix_det**是MOT17、crowdhuman、Cityscapes、ETHZ组成的联合数据集,数据集整理的格式和目录可以参考[此链接](https://github.com/ifzhang/ByteTrack#data-preparation),最终放置于`dataset/mot/`目录下。为了验证精度可以都用**MOT17-half val**数据集去评估。 + - ByteTrack的训练是单独的检测器训练MOT数据集,推理是组装跟踪器去评估MOT指标,单独的检测模型也可以评估检测指标。 + - ByteTrack的导出部署,是单独导出检测模型,再组装跟踪器运行的,参照[PP-Tracking](../../../deploy/pptracking/python/README.md)。 ## 快速开始 diff --git a/configs/mot/bytetrack/_base_/mix_mot_ch.yml b/configs/mot/bytetrack/_base_/mix_mot_ch.yml new file mode 100644 index 000000000..a19f14930 --- /dev/null +++ b/configs/mot/bytetrack/_base_/mix_mot_ch.yml @@ -0,0 +1,34 @@ +metric: COCO +num_classes: 1 + +# Detection Dataset for training +TrainDataset: + !COCODataSet + image_dir: "" + anno_path: annotations/train.json + dataset_dir: dataset/mot/mix_mot_ch + data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd'] + +EvalDataset: + !COCODataSet + image_dir: images/train + anno_path: annotations/val_half.json + dataset_dir: dataset/mot/MOT17 + +TestDataset: + !ImageFolder + anno_path: annotations/val_half.json + dataset_dir: dataset/mot/MOT17 + + +# MOTDataset for MOT evaluation and inference +EvalMOTDataset: + !MOTImageFolder + dataset_dir: dataset/mot + data_root: MOT17/images/half + keep_ori_im: True # set as True in DeepSORT and ByteTrack + +TestMOTDataset: + !MOTImageFolder + dataset_dir: dataset/mot + keep_ori_im: True # set True if save visualization images or video diff --git a/configs/mot/bytetrack/bytetrack_yolox_ht21.yml b/configs/mot/bytetrack/bytetrack_yolox_ht21.yml index d79ed6942..ea21a87c5 100644 --- a/configs/mot/bytetrack/bytetrack_yolox_ht21.yml +++ b/configs/mot/bytetrack/bytetrack_yolox_ht21.yml @@ -50,8 +50,8 @@ YOLOXHead: use_vfl: False nms: name: MultiClassNMS - nms_top_k: 1000 - keep_top_k: 100 + nms_top_k: 30000 + keep_top_k: 1000 score_threshold: 0.01 nms_threshold: 0.7 # For speed while keep high mAP, you can modify 'nms_top_k' to 1000 and 'keep_top_k' to 100, the mAP will drop about 0.1%. @@ -62,7 +62,7 @@ YOLOXHead: JDETracker: use_byte: True match_thres: 0.9 - conf_thres: 0.6 - low_conf_thres: 0.2 + conf_thres: 0.7 + low_conf_thres: 0.1 min_box_area: 0 vertical_ratio: 0 # 1.6 for pedestrian diff --git a/configs/mot/bytetrack/detector/README_cn.md b/configs/mot/bytetrack/detector/README_cn.md index dcf44ee3a..98b40bf61 100644 --- a/configs/mot/bytetrack/detector/README_cn.md +++ b/configs/mot/bytetrack/detector/README_cn.md @@ -12,19 +12,20 @@ | :-------------- | :------------- | :--------: | :---------: | :-----------: | :-----: | :------: | :-----: | | DarkNet-53 | YOLOv3 | 608X608 | 40e | ---- | 42.7 | [下载链接](https://paddledet.bj.bcebos.com/models/mot/deepsort/yolov3_darknet53_40e_608x608_mot17half.pdparams) | [配置文件](./yolov3_darknet53_40e_608x608_mot17half.yml) | | CSPResNet | PPYOLOe | 640x640 | 36e | ---- | 52.9 | [下载链接](https://paddledet.bj.bcebos.com/models/mot/deepsort/ppyoloe_crn_l_36e_640x640_mot17half.pdparams) | [配置文件](./ppyoloe_crn_l_36e_640x640_mot17half.yml) | -| CSPDarkNet | YOLOX-x | 800x1440 | 24e | ---- | 61.9 | [下载链接](https://paddledet.bj.bcebos.com/models/mot/deepsort/yolox_x_24e_800x1440_mix_det.pdparams) | [配置文件](./yolox_x_24e_800x1440_mix_det.yml) | +| CSPDarkNet | YOLOX-x(mix_mot_ch) | 800x1440 | 24e | ---- | 61.9 | [下载链接](https://paddledet.bj.bcebos.com/models/mot/deepsort/yolox_x_24e_800x1440_mix_mot_ch.pdparams) | [配置文件](./yolox_x_24e_800x1440_mix_mot_ch.yml) | +| CSPDarkNet | YOLOX-x(mix_det) | 800x1440 | 24e | ---- | 65.4 | [下载链接](https://paddledet.bj.bcebos.com/models/mot/deepsort/yolox_x_24e_800x1440_mix_det.pdparams) | [配置文件](./yolox_x_24e_800x1440_mix_det.yml) | **注意:** - 以上模型除YOLOX外采用**MOT17-half train**数据集训练,数据集可以从[此链接](https://dataset.bj.bcebos.com/mot/MOT17.zip)下载。 - **MOT17-half train**是MOT17的train序列(共7个)每个视频的前一半帧的图片和标注组成的数据集,而为了验证精度可以都用**MOT17-half val**数据集去评估,它是每个视频的后一半帧组成的,数据集可以从[此链接](https://paddledet.bj.bcebos.com/data/mot/mot17half/annotations.zip)下载,并解压放在`dataset/mot/MOT17/images/`文件夹下。 -- YOLOX采用**mix_det**数据集,是MOT17、crowdhuman、Cityscapes、ETHZ组成的联合数据集,数据集整理的格式和目录可以参考[此链接](https://github.com/ifzhang/ByteTrack#data-preparation),最终放置于`dataset/mot/`目录下。为了验证精度可以都用**MOT17-half val**数据集去评估。 + - YOLOX-x(mix_mot_ch)采用**mix_mot_ch**数据集,是MOT17、CrowdHuman组成的联合数据集;YOLOX-x(mix_det)采用**mix_det**数据集,是MOT17、CrowdHuman、Cityscapes、ETHZ组成的联合数据集,数据集整理的格式和目录可以参考[此链接](https://github.com/ifzhang/ByteTrack#data-preparation),最终放置于`dataset/mot/`目录下。为了验证精度可以都用**MOT17-half val**数据集去评估。 - 行人跟踪请使用行人检测器结合行人ReID模型。车辆跟踪请使用车辆检测器结合车辆ReID模型。 - 用于ByteTrack跟踪时,这些模型的NMS阈值等后处理设置会与纯检测任务的设置不同。 ## 快速开始 -通过如下命令一键式启动训练和评估 +通过如下命令一键式启动评估、评估和导出 ```bash job_name=ppyoloe_crn_l_36e_640x640_mot17half config=configs/mot/bytetrack/detector/${job_name}.yml @@ -32,5 +33,7 @@ log_dir=log_dir/${job_name} # 1. training python -m paddle.distributed.launch --log_dir=${log_dir} --gpus 0,1,2,3,4,5,6,7 tools/train.py -c ${config} --eval --amp # 2. evaluation -CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c ${config} -o weights=https://paddledet.bj.bcebos.com/models/mot/${job_name}.pdparams +CUDA_VISIBLE_DEVICES=0 python tools/eval.py -c ${config} -o weights=output/${job_name}/model_final.pdparams +# 3. export +CUDA_VISIBLE_DEVICES=0 python tools/export_model.py -c ${config} -o weights=output/${job_name}/model_final.pdparams ``` diff --git a/configs/mot/bytetrack/detector/yolox_x_24e_800x1440_mix_mot_ch.yml b/configs/mot/bytetrack/detector/yolox_x_24e_800x1440_mix_mot_ch.yml new file mode 100644 index 000000000..34678d52b --- /dev/null +++ b/configs/mot/bytetrack/detector/yolox_x_24e_800x1440_mix_mot_ch.yml @@ -0,0 +1,80 @@ +# This config is an assembled config for ByteTrack MOT, used as eval/infer mode for MOT. +_BASE_: [ + '../../../yolox/yolox_x_300e_coco.yml', + '../_base_/mix_mot_ch.yml', +] +weights: output/yolox_x_24e_800x1440_mix_mot_ch/model_final +log_iter: 20 +snapshot_epoch: 2 + +# schedule configuration for fine-tuning +epoch: 24 +LearningRate: + base_lr: 0.00075 # fintune + schedulers: + - !CosineDecay + max_epochs: 24 + min_lr_ratio: 0.05 + last_plateau_epochs: 4 + - !ExpWarmup + epochs: 1 + +OptimizerBuilder: + optimizer: + type: Momentum + momentum: 0.9 + use_nesterov: True + regularizer: + factor: 0.0005 + type: L2 + + +TrainReader: + batch_size: 6 + mosaic_epoch: 20 + +# detector configuration +architecture: YOLOX +pretrain_weights: https://bj.bcebos.com/v1/paddledet/models/yolox_x_300e_coco.pdparams +norm_type: sync_bn +use_ema: True +ema_decay: 0.9999 +ema_decay_type: "exponential" +act: silu +find_unused_parameters: True +depth_mult: 1.33 +width_mult: 1.25 + +YOLOX: + backbone: CSPDarkNet + neck: YOLOCSPPAN + head: YOLOXHead + input_size: [800, 1440] + size_stride: 32 + size_range: [18, 30] # multi-scale range [576*1024 ~ 800*1440], w/h ratio=1.8 + +CSPDarkNet: + arch: "X" + return_idx: [2, 3, 4] + depthwise: False + +YOLOCSPPAN: + depthwise: False + +# Tracking requires higher quality boxes, so NMS score_threshold will be higher +YOLOXHead: + l1_epoch: 20 + depthwise: False + loss_weight: {cls: 1.0, obj: 1.0, iou: 5.0, l1: 1.0} + assigner: + name: SimOTAAssigner + candidate_topk: 10 + use_vfl: False + nms: + name: MultiClassNMS + nms_top_k: 1000 + keep_top_k: 100 + score_threshold: 0.01 + nms_threshold: 0.7 + # For speed while keep high mAP, you can modify 'nms_top_k' to 1000 and 'keep_top_k' to 100, the mAP will drop about 0.1%. + # For high speed demo, you can modify 'score_threshold' to 0.25 and 'nms_threshold' to 0.45, but the mAP will drop a lot. diff --git a/configs/mot/headtracking21/README_cn.md b/configs/mot/headtracking21/README_cn.md index 2a08f0178..092dfac6c 100644 --- a/configs/mot/headtracking21/README_cn.md +++ b/configs/mot/headtracking21/README_cn.md @@ -14,7 +14,7 @@ | 模型 | 输入尺寸 | MOTA | IDF1 | IDS | FP | FN | FPS | 下载链接 | 配置文件 | | :--------------| :------- | :----: | :----: | :---: | :----: | :---: | :------: | :----: |:----: | | FairMOT DLA-34 | 1088x608 | 64.7 | 69.0 | 8533 | 148817 | 234970 | - | [下载链接](https://paddledet.bj.bcebos.com/models/mot/fairmot_dla34_30e_1088x608_headtracking21.pdparams) | [配置文件](./fairmot_dla34_30e_1088x608_headtracking21.yml) | -| ByteTrack-x | 1440x800 | 62.2 | 59.9 | 5736 | 222583 | 191737 | - | [下载链接](https://paddledet.bj.bcebos.com/models/mot/bytetrack_yolox_ht21.pdparams) | [配置文件](../bytetrack/bytetrack_yolox_ht21.yml) | +| ByteTrack-x | 1440x800 | 64.1 | 63.4 | 4191 | 185162 | 210240 | - | [下载链接](https://paddledet.bj.bcebos.com/models/mot/bytetrack_yolox_ht21.pdparams) | [配置文件](../bytetrack/bytetrack_yolox_ht21.yml) | ### FairMOT在HT-21 Test Set上结果 | 骨干网络 | 输入尺寸 | MOTA | IDF1 | IDS | FP | FN | FPS | 下载链接 | 配置文件 | diff --git a/ppdet/engine/tracker.py b/ppdet/engine/tracker.py index 84f6e092c..70c3552ac 100644 --- a/ppdet/engine/tracker.py +++ b/ppdet/engine/tracker.py @@ -20,6 +20,7 @@ import os import glob import re import paddle +import paddle.nn as nn import numpy as np from tqdm import tqdm from collections import defaultdict @@ -29,7 +30,7 @@ from ppdet.utils.checkpoint import load_weight, load_pretrain_weight from ppdet.modeling.mot.utils import Detection, get_crops, scale_coords, clip_box from ppdet.modeling.mot.utils import MOTTimer, load_det_results, write_mot_results, save_vis_results from ppdet.modeling.mot.tracker import JDETracker, DeepSORTTracker - +from ppdet.modeling.architectures import YOLOX from ppdet.metrics import Metric, MOTMetric, KITTIMOTMetric, MCMOTMetric import ppdet.utils.stats as stats @@ -60,6 +61,12 @@ class Tracker(object): # build model self.model = create(cfg.architecture) + if isinstance(self.model.detector, YOLOX): + for k, m in self.model.named_sublayers(): + if isinstance(m, nn.BatchNorm2D): + m._epsilon = 1e-3 # for amp(fp16) + m._momentum = 0.97 # 0.03 in pytorch + self.status = {} self.start_epoch = 0 -- GitLab