TEED

TEED(Tiny and Efficient Edge Detector)是一个小型卷积网络,从一张 RGB 图像预测出稠密的边缘概率图。LibreYOLO 只为边缘检测封装了它的架构;库里不附带任何检查点。

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

安装

TEED 不需要任何可选的额外依赖。它导入的所有东西都在基础安装里。

bash
pip install libreyolo

预测

LibreYOLO 不发布任何 TEED 检查点(checkpoint)。官方发布的权重是在 BIPED 上 训练的,而 BIPED 公布的数据集条款把用途限制在非商业目的,所以 LibreYOLO 不镜像 它们。用 weights/convert_teed_weights.py 转换一个你有权使用的检查点,它会 先把张量的键和运行时架构对照检查一遍,再写出一个 LibreYOLO 可以直接加载的文件:

bash
python weights/convert_teed_weights.py upstream.pth weights/LibreTEEDt-edge.pt --verify

Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("weights/LibreTEEDt-edge.pt")result = model(SAMPLE_IMAGE, save=True) edges = result.edgesprint(edges.array.shape)        # (H, W) float32,取值在 [0, 1]print(edges.binary(0.5).sum())  # 阈值化之后的边缘像素数
CLI
libreyolo predict model=weights/LibreTEEDt-edge.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True

result.edges 保存着结果:一个取值在 [0, 1] 之间的 (H, W) float32 数组, .binary(threshold) 会返回一张布尔边缘掩码。这里没有检测框,所以 confioumax_det 都不起作用。输入源、流式处理和结果处理见预测

变体

TEED 在 LibreYOLO 里只有一个尺寸。LibreYOLO 的基准测试工具还没有测过这个家族, 所以没有可以拿来对比的公开数字。

验证

val() 会在成对的边缘数据集上报告 BSDS 风格的 ODS 和 OIS F-measure:图片和同名的 边缘图放在一起,还可以带一张可选的有效性掩码,让填充像素永远不计入。imgsz 必须 能被网络的下采样步长整除,不满足时 LibreYOLO 会抛出一个明确的错误。

Python
from libreyolo import LibreYOLO model = LibreYOLO("weights/LibreTEEDt-edge.pt")metrics = model.val(data="my-dataset.yaml", imgsz=352) print(metrics["metrics/ODS"])   # 数据集最优尺度下的 F-measureprint(metrics["metrics/OIS"])   # 单图最优尺度下的 F-measure
CLI
libreyolo val model=weights/LibreTEEDt-edge.pt data=my-dataset.yaml imgsz=352

导出

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

边缘导出使用固定分辨率、batch 为 1 的运行时约定:dynamic 以及 1 以外的 batch 都会被拒绝,导出的图只输出一张融合后的概率图。导出产物按文件后缀通过 LibreYOLO() 加载回来,所以一个 .onnx 文件的表现和检查点一样,返回同样的 Results

Python
from libreyolo import LibreYOLO model = LibreYOLO("weights/LibreTEEDt-edge.pt")model.export(format="onnx", imgsz=352)model.export(format="tensorrt", imgsz=352, half=True)
CLI
libreyolo export model=weights/LibreTEEDt-edge.pt format=onnx imgsz=352libreyolo export model=weights/LibreTEEDt-edge.pt format=tensorrt imgsz=352 half=True
使用导出的文件
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("weights/LibreTEEDt-edge.onnx")result = model(SAMPLE_IMAGE) print(result.edges.array.shape)

许可

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

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

原始工作
TEED, Xavier Soria
上游许可
MIT
LibreYOLO 代码
MIT
权重
采用 MIT 许可,由作者分发。LibreYOLO 不托管或镜像这些权重。
解读
MIT is a permissive license, so the TEED architecture LibreYOLO ports can be used in commercial and closed-source products, with the license text and copyright notice kept alongside any copy you redistribute. LibreYOLO ships no checkpoint for this family: the officially released weights are trained on BIPED, whose published dataset terms restrict use to non-commercial purposes, and mirroring them would carry that restriction into a nominally MIT-licensed download. Convert a checkpoint you hold a license for with `weights/convert_teed_weights.py`; the MIT code license does not change the terms attached to whatever checkpoint you convert.

LibreYOLO 不发布任何 TEED 检查点。LibreYOLO 组织下没有镜像任何东西;请改用 weights/convert_teed_weights.py 转换一个你持有许可的检查点。

引用

@InProceedings{Soria_2023teed,
    author    = {Soria, Xavier and Li, Yachuan and Rouhani, Mohammad and Sappa, Angel D.},
    title     = {Tiny and Efficient Model for the Edge Detection Generalization},
    booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV) Workshops},
    month     = {October},
    year      = {2023},
    pages     = {1364-1373}
}

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

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