查看 Markdown

PIDNet

一个三分支语义分割网络,在受比例积分微分(proportional-integral-derivative)启发的设计上加了一条专门的边界分支,目标是实时推理。LibreYOLO 只把它用于语义分割。

任务
semantic
尺寸
s, m, l at 1024 px
安装
pip install libreyolo
支持层级
仅推理,自 v 起。仅支持预测、验证和导出。训练相关的功能不适用。
上游
PIDNet,由 Jiacong Xu 发布,采用 MIT 许可。论文源码
许可
代码采用 MIT,权重采用 MIT。商用

安装

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

bash
pip install libreyolo

预测

权重在首次使用时从 Hugging Face 下载,并缓存在本地。这个家族必须带 -sem 文件名后缀。

Python
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,已排序
CLI
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 列表。 confioumax_det 为了 API 一致而被接受,但不起作用:模型用 argmax 给 每个像素分配一个类别,没有置信度阈值,也没有 NMS 步骤。数据源、流式处理和结果 处理见预测

变体

三种尺寸,输入都固定为 1024 px。已发布的检查点(checkpoint)是官方 PIDNet Cityscapes 权重的转换版本,19 个类别。

LibreYOLO 不训练 PIDNet:对这个家族调用 train() 会抛出 NotImplementedError,上面的支持层级把它标为仅推理。

验证

val() 返回 metrics/mIoUmetrics/pixel_accuracy,在任何采用你训练所用 格式的数据集上测量。

Python
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"])
CLI
libreyolo val model=LibrePIDNets-sem.pt data=my-dataset.yaml

导出

任务ONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
semanticsemantic 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导出列出了每种 格式接受的参数。

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibrePIDNets-sem.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)
CLI
libreyolo export model=LibrePIDNets-sem.pt format=onnxlibreyolo export model=LibrePIDNets-sem.pt format=tensorrt half=True
使用导出的文件
from 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.pt1024mit
LibrePIDNetm-sem.pt1024mit
LibrePIDNetl-sem.pt1024mit

上面的每个文件目前都在 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 上提供的引用块。

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