PIDNet
一个三分支语义分割网络,在受比例积分微分(proportional-integral-derivative)启发的设计上加了一条专门的边界分支,目标是实时推理。LibreYOLO 只把它用于语义分割。
- 任务
- semantic
- 尺寸
- s, m, l at 1024 px
- 安装
pip install libreyolo- 支持层级
- 仅推理,自 v 起。仅支持预测、验证和导出。训练相关的功能不适用。
- 许可
- 代码采用 MIT,权重采用 MIT。商用
安装
PIDNet 不需要任何可选 extra。它导入的一切都在基础安装里。
pip install libreyolo预测
权重在首次使用时从 Hugging Face 下载,并缓存在本地。这个家族必须带 -sem
文件名后缀。
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibrePIDNets-sem.pt")result = model(SAMPLE_IMAGE, save=True) mask = result.semantic_maskprint(mask.data.shape) # (H, W) 类别 idprint(mask.classes) # 图像中出现的类别 id,已排序libreyolo predict model=LibrePIDNets-sem.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True语义分割返回的是每个像素一个类别 id,而不是检测框,所以 result.semantic_mask
在 .data 上带一个 (H, W) 数组,在 .classes 上带图像中出现的类别 id 列表。
conf、iou 和 max_det 为了 API 一致而被接受,但不起作用:模型用 argmax 给
每个像素分配一个类别,没有置信度阈值,也没有 NMS 步骤。数据源、流式处理和结果
处理见预测。
变体
三种尺寸,输入都固定为 1024 px。已发布的检查点(checkpoint)是官方 PIDNet Cityscapes 权重的转换版本,19 个类别。
LibreYOLO 不训练 PIDNet:对这个家族调用 train() 会抛出
NotImplementedError,上面的支持层级把它标为仅推理。
验证
val() 返回 metrics/mIoU 和 metrics/pixel_accuracy,在任何采用你训练所用
格式的数据集上测量。
from libreyolo import LibreYOLO model = LibreYOLO("LibrePIDNets-sem.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/mIoU"])print(metrics["metrics/pixel_accuracy"])libreyolo val model=LibrePIDNets-sem.pt data=my-dataset.yaml导出
| 任务 | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| semantic | semantic to ONNX:支持 | semantic to TorchScript:支持 | semantic to ExecuTorch:支持 | semantic to TensorRT:支持 | semantic to OpenVINO:支持 | semantic to Paddle:不支持 | semantic to MNN:不支持 | semantic to RKNN:不支持 | semantic to ncnn:支持 | semantic to TFLite:支持 | semantic to CoreML:不支持 | semantic to Core AI:支持 |
导出的产物按文件后缀经由 LibreYOLO() 重新加载,所以一个 .onnx 或 .engine
文件的表现和检查点一样,返回同样的 Results。导出列出了每种
格式接受的参数。
from libreyolo import LibreYOLO model = LibreYOLO("LibrePIDNets-sem.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)libreyolo export model=LibrePIDNets-sem.pt format=onnxlibreyolo export model=LibrePIDNets-sem.pt format=tensorrt half=Truefrom libreyolo import LibreYOLO, SAMPLE_IMAGE # 工厂按文件后缀分发,所以导出的产物加载方式和任何检查点一样,# 返回的也是同一个 Results 对象model = LibreYOLO("LibrePIDNets-sem.onnx")result = model(SAMPLE_IMAGE) print(result.semantic_mask.data.shape)检查点
这个家族已发布的全部权重文件。
| 文件 | 输入(px) | 权重许可 |
|---|---|---|
| semantic | ||
| LibrePIDNets-sem.pt | 1024 | mit |
| LibrePIDNetm-sem.pt | 1024 | mit |
| LibrePIDNetl-sem.pt | 1024 | mit |
上面的每个文件目前都在 LibreYOLO 组织中,并会在首次使用时下载。
许可证
请检查你所下载的具体权重在 Hugging Face 仓库中的许可。LibreYOLO 组织里的每个检查点都附有许可,同一家族内也不一定相同。该仓库是权威来源;以下摘要说明本页上次验证时适用的情况。
这里只说明涉及的许可证,不构成法律意见。如果答案对商用很重要,请自行阅读许可证并咨询法律顾问。
- 原始工作
- PIDNet, Jiacong Xu
- 上游许可
- MIT
- LibreYOLO 代码
- MIT
- 权重
- 采用 MIT 许可,重新发布在 huggingface.co/LibreYOLO
- 解读
- MIT is a permissive license, so this code and these weights can be used in commercial and closed-source products. It asks only that you keep the copyright and license notice with any copy you redistribute. LibreYOLO's checkpoints are conversions of the official PIDNet Cityscapes weights, which upstream licenses as MIT. The Cityscapes dataset itself carries separate research-oriented terms and is not redistributed by LibreYOLO.
引用
@misc{xu2022pidnet,
title={PIDNet: A Real-time Semantic Segmentation Network Inspired from PID Controller},
author={Jiacong Xu and Zixiang Xiong and Shankar P. Bhattacharyya},
year={2022},
eprint={2206.02066},
archivePrefix={arXiv},
primaryClass={cs.CV}
}复制自作者在 github.com/XuJiacong/PIDNet#bibtex-citation 上提供的引用块。