网上好多ByteTrack的部署介绍,但鲜有人提到底如何使用、如何调参,下面就我的使用经验说一说。
ByteTrack处理原理
流程图如 deepwiki.com/FoundationV…
配置原则
results = model.track(
device='cuda:0',
source=video_path, # 视频路径
conf=model_conf, # 置信度阈值。只显示置信度高于此值的检测结果,调高可减少误报,但可能漏检。
imgsz=imgsz, # 输入图像大小,默认640
tracker="ultralytics/cfg/trackers/bytetrack.yaml", # 使用ByteTrack配置文件
show=False, # 不实时显示结果
persist=True, # 保持ID在帧间持久性[citation:3]
classes=[0], # 只识别人
save=False, # 保存标注后的视频
save_dir=output_dir, # 保存目录(按时间戳命名)
save_txt=False, # 保存txt标注
save_json=True, # 保存json结果
vid_stride=1, # 视频处理步长
stream=True, # 使用流模式处理
max_det=max_det, # 增加最大检测数
verbose=True # 显示详细进度
)
tracker_type: bytetrack # (str) Tracker backend: botsort|bytetrack; choose bytetrack for the classic baseline
track_high_thresh: 0.24 # (float) First-stage match threshold; raise for cleaner tracks, lower to keep more
track_low_thresh: 0.00 # (float) Second-stage threshold for low-score matches; balances recovery vs drift
new_track_thresh: 0.25 # (float) Start a new track if no match ≥ this; higher reduces false tracks
track_buffer: 75 # (int) Frames to keep lost tracks alive; higher handles occlusion, increases ID switches risk
match_thresh: 0.75 # (float) Association similarity threshold (IoU/cost); tune with detector quality
fuse_score: false # (bool) Fuse detection score with motion/IoU for matching; stabilizes weak detections
with_reid: false # (bool) Use ReID features for matching; improves track continuity with ID switches
0、fuse_score特别重要
建议先设置为false,对于小目标和模糊的目标,这个参数可能会让本来连续的轨迹(即使人物几乎不动)中间缺帧
1、提高分辨率
yolo26的默认输入分辨率是640,如果你的输入视频分辨率比这个大,请提高imagsz参数,可直接提到视频的高度,如果运行出现问题再往下调一下1440-›1280-›960-›800
2、new_track_thresh应当比track_high_thresh高
否则如果第一次出现的人置信度比new_track_thresh高,但比track_high_thresh小,按bytetrack的原理就会进入低置信度匹配阶段,因为是新出现的人,所以匹配必定失败,然后直接被Bytetrack丢弃,所以这个人出不来(除非等到置信度比track_high_thresh大)
3、match_thresh越高匹配越宽松
过高会造成人物碰撞后ID切走了
4、如何调试
将置信高度调小,让代码跑一下样本(一两分钟)输出视频结果,使用shotcut工具一帧帧播放,查看哪些框保留,哪些不保留,记录下自己衡量的置信度,修改配置跑全文件,依次循环。
track_high_thresh: 0.1
track_low_thresh: 0.0005
new_track_thresh: 0.12
track_buffer: 150
match_thresh: 0.75
fuse_score: false
with_reid: false