查看 Markdown

DeepLabv3

一个语义分割网络,在给每个像素分类之前,先以多个膨胀率并行池化特征(空洞空间金字塔池化,atrous spatial pyramid pooling)。LibreYOLO 只把它用于语义分割。

任务
semantic
尺寸
安装
pip install libreyolo
支持层级
仅推理,自 v 起。仅支持预测、验证和导出。训练相关的功能不适用。
上游
DeepLabv3,由 PyTorch 发布,采用 BSD-3-Clause 许可。论文源码
许可
代码采用 BSD-3-Clause,权重采用 BSD-3-Clause。商用

安装

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

bash
pip install libreyolo

预测

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

Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreDeepLabv3r50-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=LibreDeepLabv3r50-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 步骤。数据源、流式处理和结果 处理见预测

变体

三种骨干:膨胀 ResNet-50、膨胀 ResNet-101 和膨胀 MobileNetV3-Large。这是 DeepLabv3,不是 DeepLabv3+,所以没有解码器阶段,也没有 CRF 精修,与 torchvision 的实现一致,而不是论文自带的参考代码。

LibreYOLO 不训练 DeepLabv3:对这个家族调用 train() 会抛出 NotImplementedError,上面的支持层级把它标为仅推理。已发布的 三个检查点(checkpoint)是 torchvision 自己的、带 VOC 标签的 COCO 权重,为 LibreYOLO 的加载器做了转换。

验证

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

Python
from libreyolo import LibreYOLO model = LibreYOLO("LibreDeepLabv3r50-sem.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/mIoU"])print(metrics["metrics/pixel_accuracy"])
CLI
libreyolo val model=LibreDeepLabv3r50-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("LibreDeepLabv3r50-sem.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)
CLI
libreyolo export model=LibreDeepLabv3r50-sem.pt format=onnxlibreyolo export model=LibreDeepLabv3r50-sem.pt format=tensorrt half=True
使用导出的文件
from libreyolo import LibreYOLO, SAMPLE_IMAGE # 工厂按文件后缀分发,所以导出的产物加载方式和任何检查点一样,# 返回的也是同一个 Results 对象model = LibreYOLO("LibreDeepLabv3r50-sem.onnx")result = model(SAMPLE_IMAGE) print(result.semantic_mask.data.shape)

检查点

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

文件输入(px)权重许可
semantic
LibreDeepLabv3r50-sem.ptbsd-3-clause
LibreDeepLabv3r101-sem.ptbsd-3-clause
LibreDeepLabv3mv3-sem.ptbsd-3-clause

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

许可证

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

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

原始工作
DeepLabv3, PyTorch
上游许可
BSD-3-Clause
LibreYOLO 代码
MIT
权重
采用 BSD-3-Clause 许可,重新发布在 huggingface.co/LibreYOLO
解读
BSD-3-Clause is a permissive license, so this code and these weights can be used in commercial and closed-source products. It asks you to keep the copyright notice, license text and a non-endorsement clause with any copy you redistribute. LibreYOLO's inference graph is torchvision's ASPP head over its ResNet-50, ResNet-101 and MobileNetV3-Large backbones; it is DeepLabv3, not DeepLabv3+, so there is no decoder or CRF, and the paper's training-only auxiliary FCN classifier is excluded. The three published checkpoints are torchvision's official COCO-with-VOC-label weights; their separate LibreYOLO Hugging Face mirrors carry BSD-3-Clause on an implied basis disclosed by torchvision rather than an explicit checkpoint-specific grant, and torchvision's own documentation notes that pretrained-model terms can depend on the training data, leaving that determination to the user.

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