Update from Sync Service

This commit is contained in:
FNS Service
2026-04-21 22:12:47 +08:00
parent 14ccba69f8
commit bdff622ab9
3 changed files with 520 additions and 0 deletions

View File

@@ -0,0 +1,219 @@
# ByteTrack 安装配置
> 环境搭建指南
---
## 环境要求
| 项目 | 要求 |
|------|------|
| Python | ≥ 3.8 |
| GPU | NVIDIA (推荐 V100) |
| CUDA | ≥ 11.1 |
| PyTorch | ≥ 1.7 |
---
## 1. 安装 ByteTrack
```bash
# 克隆代码
git clone https://github.com/ifzhang/ByteTrack.git
cd ByteTrack
# 安装依赖
pip3 install -r requirements.txt
# 安装为开发模式
python3 setup.py develop
```
## 2. 安装 COCO 评估工具
```bash
pip3 install cython
pip3 install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
```
## 3. 安装 cython_bbox
```bash
pip3 install cython_bbox
```
---
## 4. Docker 安装(推荐)
```bash
# 构建镜像
docker build -t bytetrack:latest .
# 启动容器
docker run --gpus all -it --rm \
-v $PWD/pretrained:/workspace/ByteTrack/pretrained \
-v $PWD/datasets:/workspace/ByteTrack/datasets \
bytetrack:latest
```
---
## 5. 数据集准备
### 目录结构
```
datasets/
├── mot/
│ ├── train/
│ └── test/
├── crowdhuman/
│ ├── Crowdhuman_train/
│ ├── Crowdhuman_val/
│ ├── annotation_train.odgt
│ └── annotation_val.odgt
├── MOT20/
│ ├── train/
│ └── test/
├── Cityscapes/
│ ├── images/
│ └── labels_with_ids/
└── ETHZ/
└── ...
```
### 常用数据集
| 数据集 | 用途 | 下载 |
|--------|------|------|
| MOT17 | 训练/测试 | [MOTChallenge](https://motchallenge.net/) |
| MOT20 | 拥挤场景 | [MOTChallenge](https://motchallenge.net/) |
| CrowdHuman | 预训练 | [官网](https://www.crowdhuman.org/) |
### 转换为 COCO 格式
```bash
# 转换 MOT17
python3 tools/convert_mot17_to_coco.py
# 转换 MOT20
python3 tools/convert_mot20_to_coco.py
# 转换 CrowdHuman
python3 tools/convert_crowdhuman_to_coco.py
```
---
## 6. 预训练模型下载
```bash
# 创建目录
mkdir -p pretrained
# 下载模型(根据需要)
# ByteTrack_ablation (用于消融实验)
# ByteTrack_x_mot17 (大模型)
# ByteTrack_l_mot17 (中模型)
# ByteTrack_m_mot17
# ByteTrack_s_mot17 (小模型)
```
模型下载:
- [Google Drive](https://drive.google.com/)
- [百度网盘](https://pan.baidu.com/) (提取码: eeo8)
---
## 7. YOLOX 预训练模型
从 [YOLOX Model Zoo](https://github.com/Megvii-BaseDetection/YOLOX/tree/0.1.0) 下载:
```bash
# X 模型 (精度最高)
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.0/yolox_x.pth
# 移动到预训练目录
mv yolox_x.pth pretrained/
```
---
## 8. 常用命令
### 测试追踪
```bash
# 基础追踪
python3 tools/track.py \
-f exps/example/mot/yolox_x_ablation.py \
-c pretrained/bytetrack_ablation.pth.tar \
-b 1 -d 1 --fp16 --fuse
# 使用自己的检测结果
python3 tools/demo_track.py video \
-f exps/example/mot/yolox_x_mix_det.py \
-c pretrained/bytetrack_x_mot17.pth.tar \
--fp16 --fuse --save_result
```
### 模型训练
```bash
# 消融实验
python3 tools/train.py \
-f exps/example/mot/yolox_x_ablation.py \
-d 8 -b 48 --fp16 -o \
-c pretrained/yolox_x.pth
# MOT17 完整训练
python3 tools/train.py \
-f exps/example/mot/yolox_x_mix_det.py \
-d 8 -b 48 --fp16 -o \
-c pretrained/yolox_x.pth
```
---
## 9. 部署支持
| 部署方式 | 说明 |
|----------|------|
| ONNX | Python ONNXRuntime 部署 |
| TensorRT | Python / C++ 部署 |
| ncnn | C++ 部署 |
| DeepStream | NVIDIA 边缘设备 |
详见 `deploy/` 目录。
---
## 10. 常见问题
### Q: 显存不足?
```bash
# 减小 batch size
-b 24 # 原 48
```
### Q: MOT20 边界溢出?
`yolox/data/data_augment.py` 中添加裁剪操作。
### Q: 如何使用自己的检测器?
```python
from yolox.tracker.byte_tracker import BYTETracker
tracker = BYTETracker(args)
for image in images:
dets = your_detector(image) # (N, 5) [x1,y1,x2,y2,score]
online_targets = tracker.update(dets, info_imgs, img_size)
```
---
> 参考:[ByteTrack GitHub](https://github.com/FoundationVision/ByteTrack)

View File

@@ -0,0 +1,128 @@
# ByteTrack 性能指标
> SOTA 对比与实验结果
---
## MOT17 测试集
| 指标 | 数值 | 说明 |
|------|------|------|
| **MOTA** | 80.3 | 多目标跟踪精度 |
| **IDF1** | 77.3 | 身份切换指标 |
| **HOTA** | 63.1 | 高阶跟踪精度 |
| **MT** | 53.2% | 大部分跟踪轨迹 |
| **ML** | 14.5% | 大部分丢失轨迹 |
| **FP** | 25,491 | 假阳性数 |
| **FN** | 83,721 | 假阴性数 |
| **IDs** | 2,196 | 身份切换次数 |
| **FPS** | 29.6 | 单卡 V100 |
---
## MOT20 测试集
| 指标 | 数值 |
|------|------|
| **MOTA** | 77.8 |
| **IDF1** | 75.2 |
| **HOTA** | 61.3 |
| **MT** | 69.2% |
| **ML** | 9.5% |
| **FP** | 26,249 |
| **FN** | 87,594 |
| **IDs** | 1,223 |
| **FPS** | 13.7 |
---
## 消融实验 (MOT17 Half Val)
训练数据CrowdHuman + MOT17 Half Train
| 模型 | MOTA | IDF1 | IDs | FPS |
|------|------|------|-----|-----|
| ByteTrack (消融) | 76.6 | 79.3 | 159 | 29.6 |
---
## 完整模型对比 (MOT17 Train)
| 模型 | MOTA | IDF1 | IDs | FPS |
|------|------|------|-----|-----|
| **ByteTrack-X** | 90.0 | 83.3 | 422 | 29.6 |
| **ByteTrack-L** | 88.7 | 80.7 | 460 | 43.7 |
| **ByteTrack-M** | 87.0 | 80.1 | 477 | 54.1 |
| **ByteTrack-S** | 79.2 | 74.3 | 533 | 64.5 |
---
## 轻量模型对比 (MOT17)
| 模型 | MOTA | IDF1 | IDs | 参数量 | FLOPs |
|------|------|------|-----|--------|-------|
| **ByteTrack-Nano** | 69.0 | 66.3 | 531 | 0.90M | 3.99G |
| **ByteTrack-Tiny** | 77.1 | 71.5 | 519 | 5.03M | 24.45G |
---
## MOT20 训练集
训练数据CrowdHuman + MOT20 Train
| 模型 | MOTA | IDF1 | IDs | FPS |
|------|------|------|-----|-----|
| **ByteTrack-X** | 93.4 | 89.3 | 1,057 | 17.5 |
---
## 指标说明
| 指标 | 全称 | 含义 |
|------|------|------|
| **MOTA** | Multi-Object Tracking Accuracy | 综合考虑漏检、误检、身份切换 |
| **IDF1** | IDF1 Score | 身份识别F1分数 |
| **HOTA** | Higher Order Tracking Accuracy | 高阶跟踪精度 |
| **MT** | Mostly Tracked | 80%以上被跟踪的轨迹比例 |
| **ML** | Mostly Lost | 80%以上丢失的轨迹比例 |
| **FP** | False Positive | 假阳性(误检) |
| **FN** | False Negative | 假阴性(漏检) |
| **IDs** | ID Switches | 身份切换次数 |
---
## 与其他 Tracker 对比
| Tracker | MOTA | IDF1 | FPS |
|--------|------|------|-----|
| **ByteTrack** | **80.3** | **77.3** | **29.6** |
| FairMOT | 73.7 | 72.6 | 25.9 |
| CenterTrack | 67.8 | 68.6 | 22.0 |
| Tracktor | 56.2 | 55.1 | — |
---
## ByteTrack 集成效果
ByteTrack 可提升多种 Tracker
| Tracker | 原始 IDF1 | +ByteTrack | 提升 |
|--------|-----------|------------|------|
| SORT | 64.5 | 74.8 | +10.3 |
| DeepSORT | 71.0 | 76.4 | +5.4 |
| MOTDT | 71.7 | 75.2 | +3.5 |
---
## 训练配置
| 模型 | 训练数据 | 输入尺寸 |
|------|----------|----------|
| ByteTrack-X | CrowdHuman + MOT17 + Cityperson + ETHZ | 1536×640 |
| ByteTrack-L | 同上 | 1536×640 |
| ByteTrack-M | 同上 | 896×672 |
| ByteTrack-S | 同上 | 640×480 |
---
> 数据来源:[ByteTrack GitHub](https://github.com/FoundationVision/ByteTrack)

View File

@@ -0,0 +1,173 @@
# ByteTrack 核心原理
> 多目标跟踪MOT算法详解
---
## 1. 问题背景
### 传统方法的局限
大多数 MOT 方法通过**高于阈值的高分检测框**来获取目标 ID
- 遮挡物体的检测分数较低(低分检测框)
- 低分物体被直接丢弃
- 导致**轨迹断裂**和**漏检**
### ByteTrack 的解决思路
> **核心思想**:不仅仅关联高分检测框,而是关联**所有**检测框
---
## 2. 算法流程
### Two-Stage Association
```
输入:视频序列
┌─────────────────────────────┐
│ Step 1: 高分检测框关联 │
│ (High Score Detection) │
│ 使用 IoU/特征匹配高分框 │
└─────────────┬───────────────┘
┌─────────────────────────────┐
│ Step 2: 低分检测框关联 │
│ (Low Score Detection) │
│ 利用轨迹相似度恢复目标 │
│ 过滤背景误检 │
└─────────────┬───────────────┘
输出:完整轨迹
```
### Byte 名称由来
- "Byte" = 8 bits = 256 种可能性
- 每个检测框有 0-255 的检测分数
- 关联所有分数的检测框,如同处理字节一样
---
## 3. 核心创新点
### 创新一:双重关联
| 阶段 | 输入 | 目的 |
|------|------|------|
| **第一关联** | 高分检测框 (score > θ₁) | 找到明确的目标 |
| **第二关联** | 低分检测框 (θ₂ < score ≤ θ₁) | 恢复被遮挡的目标 |
### 创新二YOLOX 检测器
ByteTrack 使用 **YOLOX** 作为检测器:
- Anchor-free 设计
- SimOTA 标签分配
- 优秀的检测性能
### 创新三:简单强大的 Tracker
- 不依赖 Re-ID 特征
- 仅使用 **IoU** 关联
- 高效且易于部署
---
## 4. 匹配策略
### 卡尔曼滤波
- 预测下一帧目标位置
- 处理物体运动平滑
### IoU 匹配
```python
# 高分关联
matched, unmatched_dets = IoUMatching(tracklets, high_score_dets)
# 低分关联(仅对未匹配轨迹)
matched, unmatched_tracks = IoUMatching(unmatched_tracks, low_score_dets)
```
### 阈值设置
| 参数 | 说明 | 典型值 |
|------|------|--------|
| `high_score_thresh` | 高分阈值 | 0.5 |
| `match_thresh` | IoU 匹配阈值 | 0.8 |
| `low_score_thresh` | 低分阈值 | 0.6 |
---
## 5. 为什么有效?
### 遮挡场景示例
```
帧 1: [Person A] → 检测分数 0.95 ✓
帧 2: [Person A] → 检测分数 0.85 ✓
帧 3: [被遮挡] → 检测分数 0.35 ✗ (传统方法丢弃)
ByteTrack 处理:
- 帧 1-2: 正常关联,建立轨迹
- 帧 3: 低分框仍参与第二关联
- 利用运动预测 + IoU 匹配
- 成功恢复被遮挡目标
```
### 效果提升
| 指标 | 提升 | 原因 |
|------|------|------|
| MOTA | +2-3% | 减少漏检 |
| IDF1 | +1-10% | 轨迹更连续 |
| IDs | 大幅减少 | 减少轨迹断裂 |
---
## 6. 与其他 Tracker 对比
ByteTrack 可集成到多种现有 tracker
- ✅ ByteTrack + SORT
- ✅ ByteTrack + DeepSORT
- ✅ ByteTrack + MOTDT
所有组合都获得 **一致的性能提升**
---
## 7. 核心代码框架
```python
class BYTETracker:
def __init__(self, args):
self.high_score_thresh = args.track_thresh
self.low_score_thresh = args.low_thresh
self.match_thresh = args.match_thresh
def update(self, dets, frame_info):
# 分离高低分检测框
high_dets = dets[dets[:, 4] >= self.high_score_thresh]
low_dets = dets[dets[:, 4] < self.high_score_thresh]
# 第一阶段:高分关联
online_targets = self.associate(high_dets, tracks)
# 第二阶段:低分关联
online_targets = self.associate_low(online_targets, low_dets)
return online_targets
```
---
## 8. 参考
- **论文**[ByteTrack: Multi-Object Tracking by Associating Every Detection Box](https://arxiv.org/abs/2110.06864)
- **代码**[FoundationVision/ByteTrack](https://github.com/FoundationVision/ByteTrack)
- **发表**ECCV 2022