查看 Markdown

CenterNet

CenterNet 把一个目标建模为它检测框的中心点,其余所有属性都从热力图的一个峰值回归得到,所以它既不需要锚框,也不需要非极大值抑制(non-maximum-suppression)步骤。LibreYOLO 以仅推理的检测器形式提供它。

任务
detection
尺寸
resdcn18, dla34 at 512 px
安装
pip install libreyolo
支持层级
仅推理,自 v 起。仅支持预测、验证和导出。训练相关的功能不适用。
上游
CenterNet,由 UT Austin and UC Berkeley 发布,采用 MIT 许可。论文源码
许可
代码采用 MIT,权重采用 MIT。商用

安装

CenterNet 不需要任何可选 extra。它导入的一切都在基础安装里。

bash
pip install libreyolo

预测

权重在首次使用时从 Hugging Face 下载,并缓存在本地。

Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreCenterNetresdcn18.pt")result = model(SAMPLE_IMAGE, save=True) for box in result.boxes:    print(box.cls, box.conf, box.xyxy)
CLI
libreyolo predict model=LibreCenterNetresdcn18.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True
DLA-34
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreCenterNetdla34.pt")result = model(SAMPLE_IMAGE, save=True)

返回的 Results 对象就是每个家族都会返回的那一个,所以换成另一个检测器只是改 一行的事。confmax_det 会过滤排好序的热力图峰值;iou 为了 API 一致性会 被接受,但不起作用,因为 CenterNet 的 top-k 峰值解码不需要基于检测框 IoU 的抑制 步骤。数据源、流式处理和结果处理见预测

变体

两种骨干。resdcn18 把 ResNet-18 主干和可变形卷积上采样配在一起;dla34 把 DLA-34 主干和迭代式深度聚合上采样配在一起。两者接的是同样的三个稠密 head(热力 图、宽/高、偏移),输入画布也一样。

验证

val() 返回一个由 metrics/ 键组成的字典,涵盖查准率、查全率、mAP 50 和 mAP 50-95,在任何采用你训练时所用格式的数据集上测量。

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreCenterNetresdcn18.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/mAP50-95"])print(metrics["metrics/mAP50"])
CLI
libreyolo val model=LibreCenterNetresdcn18.pt data=my-dataset.yaml

导出

任务ONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
DetectionDetection to ONNX:支持Detection to TorchScript:支持Detection to ExecuTorch:支持Detection to TensorRT:支持Detection to OpenVINO:支持Detection to Paddle:不支持Detection to MNN:不支持Detection to RKNN:不支持Detection to ncnn:不支持Detection to TFLite:不支持Detection to CoreML:不支持Detection to Core AI:不支持

导出 ONNX 需要 opset 16 或更高:两种骨干里的可变形卷积上采样阶段都会下降为 ONNX 的 GridSample 算子,而这个算子是 opset 16 引入的。请求更低的 opset 会在追踪开始 前就抛出异常。

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreCenterNetresdcn18.pt") # 导出 ONNX 需要 opset 16 或更高:可变形卷积的上采样阶段会# 下降为 GridSample,而 GridSample 是 opset 16 引入的model.export(format="onnx", opset=18)model.export(format="tensorrt")
CLI
libreyolo export model=LibreCenterNetresdcn18.pt format=onnx opset=18
使用导出的文件
from libreyolo import LibreYOLO # 工厂按文件后缀分发,所以导出的产物加载方式和任何检查点一样,# 返回的也是同一个 Results 对象model = LibreYOLO("LibreCenterNetresdcn18.onnx")result = model(SAMPLE_IMAGE) print(result.boxes.xyxy)

检查点

这个家族已发布的全部权重文件。

文件输入(px)权重许可
Detection
LibreCenterNetresdcn18.pt512mit
LibreCenterNetdla34.pt512mit

上面的每个文件目前都在 LibreYOLO 组织中,并会在首次使用时下载。

许可证

请检查你所下载的具体权重在 Hugging Face 仓库中的许可。LibreYOLO 组织里的每个检查点都附有许可,同一家族内也不一定相同。该仓库是权威来源;以下摘要说明本页上次验证时适用的情况。

这里只说明涉及的许可证,不构成法律意见。如果答案对商用很重要,请自行阅读许可证并咨询法律顾问。

原始工作
CenterNet, UT Austin and UC Berkeley
上游许可
MIT
LibreYOLO 代码
MIT
权重
采用 MIT 许可,重新发布在 huggingface.co/LibreYOLO
解读
MIT is a permissive license, so these weights can be used in commercial and closed-source products. It asks only that you keep the copyright notice and license text with any copy you redistribute, and it places no obligation on your own application code. The official ResDCN-18 and DLA-34 COCO checkpoints were published by the MIT-licensed CenterNet project but carry no separate per-checkpoint license file; LibreYOLO's mirror states MIT as implied by the releasing project rather than a publisher-confirmed, checkpoint-specific grant.

ResDCN-18 的计算图还要归功于微软采用 MIT 许可的 human-pose-estimation.pytorch, DLA-34 的计算图则归功于 Fisher Yu 采用 BSD-3-Clause 许可的 DLA 实现。LibreYOLO 没有随库内置上游项目当年使用的原版 DCNv2 扩展;原生执行改用 torchvision 采用 BSD-3-Clause 许可的 deform_conv2d,而仅用于导出的可移植实现是为 LibreYOLO 单独 编写的。

引用

@inproceedings{zhou2019objects,
  title={Objects as Points},
  author={Zhou, Xingyi and Wang, Dequan and Kr{\"a}henb{\"u}hl, Philipp},
  booktitle={arXiv preprint arXiv:1904.07850},
  year={2019}
}

复制自作者在 github.com/xingyizhou/CenterNet#citation 上提供的引用块。

已针对 LibreYOLO v1.5.0 验证。本页的支持表、检查点和基准测试数据由已发布的库和权重生成,并非手工编写。