py-motmetrics

cheindMIT活跃维护

用 Python 对多目标跟踪器做基准评测,计算 CLEAR MOT 等标准指标,方便横向对比不同跟踪算法的效果。

:bar_chart: Benchmark multiple object trackers (MOT) in Python

v1.4.0发布于 2024-10-30 19:45 UTC1,486star261fork同步于 2026-11-07 07:32 UTC

怎么上手

由 README 提炼,执行前请确认
pip install motmetrics
硬件要求按 README 说明

README 未说明,纯 Python 计算,无 GPU 或显存要求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Python 评估多目标跟踪结果的工具库,对齐 MOTChallenge 指标,快速算出 MOTA、IDF1、HOTA

用 Python 对多目标跟踪器做基准评测,计算 CLEAR MOT 等标准指标,方便横向对比不同跟踪算法的效果。

核心能力

  • 实现 CLEAR MOT、Identity 与 HOTA 系列指标
  • 一行 evaluate_motchallenge 自动识别格式并输出指标表
  • 支持 MOTChallenge、VATIC、UA-DETRAC 的文本与 MAT/XML 格式
  • 提供 MOTAccumulator 累积帧级匹配事件,可自定义指标
  • 内置 IoU、欧氏距离等距离矩阵辅助函数

容易踩的坑

需要 Python 3.8 至 3.14;MOTP 输出的是平均距离而非百分比,需用 (1 - MOTP) * 100 换算成 MOTChallenge 口径;FAR 不直接给出,需自行按每帧误检数计算

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

1 个版本v1.4.0
  1. v1.4.0最新正式版2024-10-30 · 2024-10-30 19:45 UTC

    What's Changed

    New Contributors

    Full Changelog: https://github.com/cheind/py-motmetrics/compare/v1.3.0...v1.4.0

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    PyPI version Build Status DOI

    py-motmetrics

    py-motmetrics provides Python tools for evaluating multiple object tracking (MOT) results. It implements MOTChallenge-aligned CLEAR MOT, Identity, and HOTA-related metrics, including MOTA, MOTP, IDF1, precision, recall, and track quality counts.

    Installation

    pip install motmetrics
    

    Python 3.8 through 3.14 is supported.

    For development:

    uv venv
    uv pip install --group dev
    

    Quick Start

    For MOTChallenge-style text files, compute and print metrics in one call. Supported file formats are detected automatically.

    import motmetrics as mm
    
    summary = mm.evaluate_motchallenge("path/to/gt.txt", "path/to/pred.txt")
    print(summary)
    

    summary displays as a MOTChallenge-style table and keeps the raw pandas data available:

    summary.mota
    summary.idf1
    summary.hota
    summary.df.to_csv("metrics.csv")
    

    By default, evaluate_motchallenge uses fmt="auto". It detects MOTChallenge text, VATIC text, and UA-DETRAC .mat/.xml files. For ambiguous text files, pass the format explicitly:

    summary = mm.evaluate_motchallenge(gt, pred, fmt=mm.io.Format.MOT16)
    

    Folder evaluation uses the same function:

    summary = mm.evaluate_motchallenge("path/to/gt_root", "path/to/preds_root")
    print(summary)
    

    Expected folder layout:

    gt_root/<SEQUENCE>/gt/gt.txt
    preds_root/<SEQUENCE>.txt
    

    The command-line evaluator is still available:

    python -m motmetrics.apps.eval_motchallenge path/to/gt_root path/to/preds_root
    

    Metrics

    List all registered metrics:

    import motmetrics as mm
    
    print(mm.list_metrics_markdown())
    

    The default MOTChallenge summary includes the commonly reported CLEAR, Identity, and HOTA metrics.

    Advanced Use

    Useful lower-level pieces:

    • mm.MOTAccumulator stores frame-level matching events.
    • mm.distances contains distance helpers such as IoU and Euclidean matrices.
    • mm.io.loadtxt(..., fmt="auto") detects MOTChallenge text, VATIC text, and UA-DETRAC MAT/XML files.
    • mm.metrics.create() returns a MetricsHost for custom metric selection.
    • mm.utils.compare_to_groundtruth compares loaded dataframes directly.
    • mm.utils.compare_to_groundtruth_reweighting supports custom HOTA-style multi-threshold workflows.

    For the full HOTA/CLEAR/Identity parity check against TrackEval, see motmetrics/tests/test_trackeval_parity.py.

    MOTChallenge Notes

    Results are aligned with the MOTChallenge devkit, with two naming/format differences:

    • FAR is not listed directly; it can be computed as false positives per frame.
    • MOTChallenge reports MOTP as a percentage, while py-motmetrics reports the average distance. Convert with (1 - MOTP) * 100 for MOTChallenge-style MOTP.

    Development

    Run the test suite:

    uv run --no-project pytest
    

    Run the TrackEval parity test locally:

    uv pip install trackeval==1.3.0
    uv run --no-project pytest -q motmetrics/tests/test_trackeval_parity.py
    

    References

    1. Bernardin, Keni, and Rainer Stiefelhagen. "Evaluating multiple object tracking performance: the CLEAR MOT metrics." EURASIP Journal on Image and Video Processing, 2008.
    2. Milan, Anton, et al. "MOT16: A benchmark for multi-object tracking." arXiv preprint arXiv:1603.00831, 2016.
    3. Li, Yuan, Chang Huang, and Ram Nevatia. "Learning to associate: HybridBoosted multi-target tracker for crowded scene." CVPR, 2009.
    4. Ristani, Ergys, et al. "Performance Measures and a Data Set for Multi-Target, Multi-Camera Tracking." ECCV Workshop, 2016.

    License

    MIT. See LICENSE.