FCOS
FCOS 逐像素检测目标,而不依赖一组预定义的锚框,它在特征图的每个位置上都预测一个检测框和一个中心度(centerness)分数。LibreYOLO 移植了 torchvision 的实现,用于检测。
- 任务
- detection
- 尺寸
- r50 at 800 px
- 安装
pip install libreyolo- 支持层级
- 仅推理,自 v 起。仅支持预测、验证和导出。训练相关的功能不适用。
- 许可
- 代码采用 BSD-3-Clause,权重采用 BSD-3-Clause。商用
安装
FCOS 不需要任何可选 extra。它导入的一切都在基础安装里。
pip install libreyolo预测
权重在首次使用时从 Hugging Face 下载,并缓存在本地。
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreFCOSr50.pt")result = model(SAMPLE_IMAGE, save=True) for box in result.boxes: print(box.cls, box.conf, box.xyxy)libreyolo predict model=LibreFCOSr50.pt source=https://raw.githubusercontent.com/LibreYOLO/libreyolo/release/libreyolo/assets/parkour.jpg save=True返回的 Results 对象就是每个家族都返回的那一个,所以换用另一个检测器只是一行
改动。调用模型时不传任何阈值参数,会套用 FCOS 自己公布的默认值 conf=0.2、
iou=0.6 和 max_det=100;这三个里传进任意一个都会覆盖掉默认值。FCOS 在它逐
像素的预测之上保留了一个最终的 NMS 步骤。数据源、流式处理和结果处理见
预测。
变体
只有一种尺寸:带特征金字塔的 ResNet-50,这是这个家族认可的唯一变体。
验证
val() 返回一个由 metrics/ 键组成的字典,涵盖查准率、查全率、mAP 50 和
mAP 50-95,在任何采用你训练时所用格式的数据集上测量。
from libreyolo import LibreYOLO model = LibreYOLO("LibreFCOSr50.pt")metrics = model.val(data="my-dataset.yaml") print(metrics["metrics/mAP50-95"])print(metrics["metrics/mAP50"])libreyolo val model=LibreFCOSr50.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:不支持 |
FCOS 可以导出到 ONNX、TorchScript 和 OpenVINO。FCOS 在计算图运行之前会保留原图
的宽高比,所以不管传进来的是什么,LibreYOLO 都会为 ONNX 和 OpenVINO 这两条路径
强制 dynamic=True,好让计算图对填充后的输入形状依然有效。导出的 .onnx 文件
按文件后缀经由 LibreYOLO() 重新加载,返回的还是同一个 Results。
from libreyolo import LibreYOLO model = LibreYOLO("LibreFCOSr50.pt")model.export(format="onnx", imgsz=800)model.export(format="torchscript", imgsz=800)libreyolo export model=LibreFCOSr50.pt format=onnx imgsz=800from libreyolo import LibreYOLO, SAMPLE_IMAGE # 工厂按文件后缀分发,所以导出的产物加载方式和任何检查点一样,# 返回的也是同一个 Results 对象model = LibreYOLO("LibreFCOSr50.onnx")result = model(SAMPLE_IMAGE) print(result.boxes.xyxy)检查点
这个家族已发布的全部权重文件。
| 文件 | 输入(px) | 权重许可 |
|---|---|---|
| Detection | ||
| LibreFCOSr50.pt | 800 | bsd-3-clause |
上面的每个文件目前都在 LibreYOLO 组织中,并会在首次使用时下载。
许可证
请检查你所下载的具体权重在 Hugging Face 仓库中的许可。LibreYOLO 组织里的每个检查点都附有许可,同一家族内也不一定相同。该仓库是权威来源;以下摘要说明本页上次验证时适用的情况。
这里只说明涉及的许可证,不构成法律意见。如果答案对商用很重要,请自行阅读许可证并咨询法律顾问。
- 原始工作
- FCOS, PyTorch
- 上游许可
- BSD-3-Clause
- LibreYOLO 代码
- MIT
- 权重
- 采用 BSD-3-Clause 许可,重新发布在 huggingface.co/LibreYOLO
- 解读
- BSD-3-Clause is a permissive license, so this code can be used in commercial and closed-source products with no obligation on your own application code. It asks only that you keep the copyright notice and disclaimer with any copy you redistribute, and it carries no patent grant. The published checkpoint used for parity testing is not distributed in the LibreYOLO source tree: torchvision's own documentation notes that a pretrained model's terms may depend on its training data, so the Hugging Face mirror ships the BSD text on that implied basis and repeats the caveat rather than issuing an explicit checkpoint-specific grant.
引用
@inproceedings{tian2019fcos,
title = {{FCOS}: Fully Convolutional One-Stage Object Detection},
author = {Tian, Zhi and Shen, Chunhua and Chen, Hao and He, Tong},
booktitle = {Proc. Int. Conf. Computer Vision (ICCV)},
year = {2019}
}
@article{tian2021fcos,
title = {{FCOS}: A Simple and Strong Anchor-free Object Detector},
author = {Tian, Zhi and Shen, Chunhua and Chen, Hao and He, Tong},
booktitle = {IEEE T. Pattern Analysis and Machine Intelligence (TPAMI)},
year = {2021}
}复制自作者在 github.com/tianzhi0549/FCOS#citations 上提供的引用块。