EfficientDet
EfficientDet 把 EfficientNet 骨干和重复堆叠的双向特征金字塔网络(BiFPN)配在一起,并在五种尺寸上同时缩放深度、宽度和分辨率。LibreYOLO 以仅推理的检测器形式提供它。
- 任务
- detection
- 尺寸
- 安装
pip install libreyolo- 支持层级
- 仅推理,自 v 起。仅支持预测、验证和导出。训练相关的功能不适用。
- 许可
- 代码采用 Apache-2.0,权重采用 Apache-2.0。商用
安装
EfficientDet 不需要任何可选 extra。它导入的一切都在基础安装里。
pip install libreyolo预测
权重在首次使用时从 Hugging Face 下载,并缓存在本地。
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreEfficientDetd0.pt")result = model(SAMPLE_IMAGE, save=True) for box in result.boxes: print(box.cls, box.conf, box.xyxy)libreyolo predict model=LibreEfficientDetd0.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True返回的 Results 对象就是每个家族都会返回的那一个,所以换成另一个检测器只是改
一行的事。EfficientDet 先解码基于锚框的候选,再做逐类别的非极大值抑制,所以
conf、iou 和 max_det 在这里都会真正起作用。数据源、流式处理和结果处理
见预测。
变体
五种尺寸,从 D0 到 D4。每上一档都会把更大的 EfficientNet 骨干和更深、更宽的 BiFPN 以及更深的预测 head 配在一起,所以参数量和计算量一起增长,遵循论文的复合 缩放(compound scaling)规则。
验证
val() 返回一个由 metrics/ 键组成的字典,涵盖查准率、查全率、mAP 50 和
mAP 50-95,在任何采用你训练时所用格式的数据集上测量。
from libreyolo import LibreYOLO model = LibreYOLO("LibreEfficientDetd0.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/mAP50-95"])print(metrics["metrics/mAP50"])libreyolo val model=LibreEfficientDetd0.pt data=my-dataset.yaml导出
| 任务 | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Detection | Detection 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:不支持 |
导出的产物会按文件后缀通过 LibreYOLO() 重新加载,所以一个 .onnx 或 .engine
文件的行为和检查点(checkpoint)一样,返回的也是同一个 Results。
from libreyolo import LibreYOLO model = LibreYOLO("LibreEfficientDetd0.pt")model.export(format="onnx")model.export(format="tensorrt", half=True)libreyolo export model=LibreEfficientDetd0.pt format=onnxlibreyolo export model=LibreEfficientDetd0.pt format=tensorrt half=Truefrom libreyolo import LibreYOLO # 工厂按文件后缀分发,所以导出的产物加载方式和任何检查点一样,# 返回的也是同一个 Results 对象model = LibreYOLO("LibreEfficientDetd0.onnx")result = model(SAMPLE_IMAGE) print(result.boxes.xyxy)检查点
这个家族已发布的全部权重文件。
| 文件 | 输入(px) | 权重许可 |
|---|---|---|
| Detection | ||
| LibreEfficientDetd0.pt | apache-2.0 | |
| LibreEfficientDetd1.pt | apache-2.0 | |
| LibreEfficientDetd2.pt | apache-2.0 | |
| LibreEfficientDetd3.pt | apache-2.0 | |
| LibreEfficientDetd4.pt | apache-2.0 | |
上面的每个文件目前都在 LibreYOLO 组织中,并会在首次使用时下载。
许可证
请检查你所下载的具体权重在 Hugging Face 仓库中的许可。LibreYOLO 组织里的每个检查点都附有许可,同一家族内也不一定相同。该仓库是权威来源;以下摘要说明本页上次验证时适用的情况。
这里只说明涉及的许可证,不构成法律意见。如果答案对商用很重要,请自行阅读许可证并咨询法律顾问。
- 原始工作
- EfficientDet, Google Research
- 上游许可
- Apache-2.0
- LibreYOLO 代码
- MIT
- 权重
- 采用 Apache-2.0 许可,重新发布在 huggingface.co/LibreYOLO
- 解读
- Apache-2.0 is a permissive license, so these weights can be used in commercial and closed-source products. It asks you to keep its license text and attribution notices with any copy of the weights you redistribute, and it grants a patent license. It places no obligation on your own application code. LibreYOLO's D0-D4 checkpoints are converted from Google's official TensorFlow-trained release assets through the Apache-2.0 rwightman/efficientdet-pytorch project; those release assets carry no separate per-checkpoint license, so redistribution here rests on Apache-2.0 implied by the releasing project, the same basis rwightman/efficientdet-pytorch itself uses for its own converted weights.
LibreYOLO 的 D0-D4 检查点是通过采用 Apache-2.0 许可的 rwightman/efficientdet-pytorch 项目转换而来的,该项目本身镜像了 google/automl 里官方用 TensorFlow 训练出的权重, 没有改动学到的张量。采用 LGPL 许可的 zylo117/Yet-Another-EfficientDet-Pytorch 项目里的源码没有被参考或使用。