RF-DETR:实时 SOTA 目标检测、实例分割与关键点检测
RF-DETR 是由 Roboflow 开发的一种用于目标检测、实例分割和关键点检测(预览)的实时 transformer 架构。基于 DINOv2 视觉 transformer 骨干网络,RF-DETR 在 Microsoft COCO 和 RF100-VL 上实现了最先进的精度与延迟权衡。
RF-DETR 使用 DINOv2 视觉 transformer 骨干网络,并通过单一、一致的 API 支持目标检测、实例分割和关键点检测(预览)。开源 rfdetr 包和指定为 Apache 的模型以 Apache 2.0 许可证发布,而 Plus 组件(rfdetr_plus,包括 RF-DETR-XL/2XL 检测模型)则采用 PML 1.0 许可证。
已发布的 RF-DETR 尺寸是通过神经架构搜索(NAS)创建的——同样的 NAS 方法现已在 Roboflow 平台 上可用,因此您可以为自己的数据集发现最佳架构。更多信息请参阅 NAS 文档。
https://github.com/user-attachments/assets/add23fd1-266f-4538-8809-d7dd5767e8e6
安装
要安装 RF-DETR,请在 rfdetr 包中,使用 pip 在 Python>=3.10 环境中进行安装。
pip install rfdetr
从源代码安装
通过从源代码安装 RF-DETR,您可以探索尚未正式发布的最新特性和增强功能。请注意,这些更新仍处于开发阶段,可能不如最新发布的版本稳定。
pip install https://github.com/roboflow/rf-detr/archive/refs/heads/develop.zip
基准测试
RF-DETR 在目标检测和实例分割方面均取得了最先进的结果,基准测试在 Microsoft COCO 和 RF100-VL 上报告(RF100-VL 仅用于检测)。下图和下表比较了 RF-DETR 与其他顶级实时模型在检测和分割方面的精度与延迟。所有 COCO 精度数值均为内部针对每个所示模型进行测量,使用 pycocotools 在 SAB 上针对完整的 5,000 张图像 val2017 分割集计算得出,因此每一行都可直接比较,且可能与厂商报告的数值不同。唯一的例外是标记为 † 的行,这些数值引用自原作者的论文,未在 SAB 中进行测量。所有延迟数值均在 NVIDIA T4 上使用 TensorRT、FP16 和批处理大小 1 进行测量。参数量是部署(融合)nn.Module 参数量(model.parameters(),而非保存检查点的原始张量计数),标记为 † 的行除外,这些行是作者报告的计数。有关完整的基准测试方法和可复现性详情,请参阅 roboflow/sab.
检测
查看目标检测基准测试数值
| Architecture | COCO AP50 | COCO AP50:95 | RF100VL AP50 | RF100VL AP50:95 | Latency (ms) | Params (M) | Resolution | License |
|---|---|---|---|---|---|---|---|---|
| RF-DETR-N | 67.6 | 48.4 | 85.0 | 57.7 | 2.3 | 30.5 | 384x384 | Apache 2.0 |
| RF-DETR-S | 72.1 | 53.0 | 86.7 | 60.2 | 3.5 | 32.1 | 512x512 | Apache 2.0 |
| RF-DETR-M | 73.6 | 54.7 | 87.4 | 61.2 | 4.4 | 33.7 | 576x576 | Apache 2.0 |
| RF-DETR-L | 75.1 | 56.5 | 88.2 | 62.2 | 6.8 | 33.9 | 704x704 | Apache 2.0 |
| RF-DETR-XL △ | 77.4 | 58.6 | 88.5 | 62.9 | 11.5 | 126.4 | 700x700 | PML 1.0 |
| RF-DETR-2XL △ | 78.5 | 60.1 | 89.0 | 63.2 | 17.2 | 126.9 | 880x880 | PML 1.0 |
| YOLO11-N | 52.0 | 37.4 | 81.4 | 55.3 | 2.5 | 2.6 | 640x640 | AGPL-3.0 |
| YOLO11-S | 59.7 | 44.4 | 82.3 | 56.2 | 3.2 | 9.4 | 640x640 | AGPL-3.0 |
| YOLO11-M | 64.1 | 48.6 | 82.5 | 56.5 | 5.1 | 20.1 | 640x640 | AGPL-3.0 |
| YOLO11-L | 64.9 | 49.9 | 82.2 | 56.5 | 6.5 | 25.3 | 640x640 | AGPL-3.0 |
| YOLO11-X | 66.1 | 50.9 | 81.7 | 56.2 | 10.5 | 56.9 | 640x640 | AGPL-3.0 |
| YOLO26-N | 55.8 | 40.3 | 76.7 | 52.0 | 1.7 | 2.6 | 640x640 | AGPL-3.0 |
| YOLO26-S | 64.3 | 47.7 | 82.7 | 57.0 | 2.6 | 9.4 | 640x640 | AGPL-3.0 |
| YOLO26-M | 69.7 | 52.5 | 84.4 | 58.7 | 4.4 | 20.1 | 640x640 | AGPL-3.0 |
| YOLO26-L | 71.1 | 54.1 | 85.0 | 59.3 | 5.7 | 25.3 | 640x640 | AGPL-3.0 |
| YOLO26-X | 74.0 | 56.9 | 85.6 | 60.0 | 9.6 | 56.9 | 640x640 | AGPL-3.0 |
| LW-DETR-T | 60.7 | 42.9 | 84.7 | 57.1 | 1.9 | 12.1 | 640x640 | Apache 2.0 |
| LW-DETR-S | 66.8 | 48.0 | 85.0 | 57.4 | 2.6 | 14.6 | 640x640 | Apache 2.0 |
| LW-DETR-M | 72.0 | 52.6 | 86.8 | 59.8 | 4.4 | 28.2 | 640x640 | Apache 2.0 |
| LW-DETR-L | 74.6 | 56.1 | 87.4 | 61.5 | 6.9 | 46.8 | 640x640 | Apache 2.0 |
| LW-DETR-X | 76.9 | 58.3 | 87.9 | 62.1 | 13.0 | 118.0 | 640x640 | Apache 2.0 |
| D-FINE-N | 60.2 | 42.7 | 84.4 | 58.2 | 2.1 | 3.8 | 640x640 | Apache 2.0 |
| D-FINE-S | 67.6 | 50.6 | 85.3 | 60.3 | 3.5 | 10.2 | 640x640 | Apache 2.0 |
| D-FINE-M | 72.6 | 55.0 | 85.5 | 60.6 | 5.4 | 19.2 | 640x640 | Apache 2.0 |
| D-FINE-L | 74.9 | 57.2 | 86.4 | 61.6 | 7.5 | 31.0 | 640x640 | Apache 2.0 |
| D-FINE-X | 76.8 | 59.3 | 86.9 | 62.2 | 11.5 | 62.0 | 640x640 | Apache 2.0 |
| SAM 3 † | — | — | — | 61.6 | — | ~850 | 1008x1008 | N/A |
† 由 SAM 3 作者报告(arXiv:2511.16719, Table 36]),并非我们在 SAB 中测量的结果。该数值是 SAM 3 在完整的 RF100-VL 训练集上微调后的结果,这与上述 RF100VL 列的设置相同——SAM 3 的论文报告 LW-DETR-m 在该基准上为 59.8,与我们自己的测量结果一致,因此数据吻合。破折号表示 SAM 3 在此协议下未报告的结果。参数量是论文中所述的约 850 M(约 450 M 视觉 + 约 300 M 文本编码器 + 约 100 M 检测器/跟踪器)。
分割
查看实例分割基准数据
| Architecture | COCO AP50 | COCO AP50:95 | Latency (ms) | Params (M) | Resolution | License |
|---|---|---|---|---|---|---|
| RF-DETR-Seg-N | 63.0 | 40.3 | 3.4 | 33.6 | 312x312 | Apache 2.0 |
| RF-DETR-Seg-S | 66.2 | 43.1 | 4.4 | 33.7 | 384x384 | Apache 2.0 |
| RF-DETR-Seg-M | 68.4 | 45.3 | 5.9 | 35.7 | 432x432 | Apache 2.0 |
| RF-DETR-Seg-L | 70.5 | 47.1 | 8.8 | 36.2 | 504x504 | Apache 2.0 |
| RF-DETR-Seg-XL | 72.2 | 48.8 | 13.5 | 38.1 | 624x624 | Apache 2.0 |
| RF-DETR-Seg-2XL | 73.1 | 49.9 | 21.8 | 38.6 | 768x768 | Apache 2.0 |
| YOLOv8-N-Seg | 45.6 | 28.3 | 3.5 | 3.4 | 640x640 | AGPL-3.0 |
| YOLOv8-S-Seg | 53.8 | 34.0 | 4.2 | 11.8 | 640x640 | AGPL-3.0 |
| YOLOv8-M-Seg | 58.2 | 37.3 | 7.0 | 27.3 | 640x640 | AGPL-3.0 |
| YOLOv8-L-Seg | 60.5 | 39.0 | 9.7 | 46.0 | 640x640 | AGPL-3.0 |
| YOLOv8-XL-Seg | 61.3 | 39.5 | 14.0 | 71.8 | 640x640 | AGPL-3.0 |
| YOLOv11-N-Seg | 47.8 | 30.0 | 3.6 | 2.9 | 640x640 | AGPL-3.0 |
| YOLOv11-S-Seg | 55.4 | 35.0 | 4.6 | 10.1 | 640x640 | AGPL-3.0 |
| YOLOv11-M-Seg | 60.0 | 38.5 | 6.9 | 22.4 | 640x640 | AGPL-3.0 |
| YOLOv11-L-Seg | 61.5 | 39.5 | 8.3 | 27.6 | 640x640 | AGPL-3.0 |
| YOLOv11-XL-Seg | 62.4 | 40.1 | 13.7 | 62.1 | 640x640 | AGPL-3.0 |
| YOLO26-N-Seg | 54.3 | 34.7 | 2.31 | 2.7 | 640x640 | AGPL-3.0 |
| YOLO26-S-Seg | 62.4 | 40.2 | 3.47 | 10.4 | 640x640 | AGPL-3.0 |
| YOLO26-M-Seg | 67.8 | 44.0 | 6.32 | 23.6 | 640x640 | AGPL-3.0 |
| YOLO26-L-Seg | 69.8 | 45.5 | 7.58 | 28.0 | 640x640 | AGPL-3.0 |
| YOLO26-X-Seg | 71.6 | 46.8 | 12.92 | 62.8 | 640x640 | AGPL-3.0 |
关键点
查看关键点检测基准数据
| Architecture | COCO AP50:95 | Latency (ms) | Params (M) | License |
|---|---|---|---|---|
| RF-DETR Keypoint (Preview) | 71.8 | 9.7 | 40.7 | Apache 2.0 |
| YOLO11-pose N | 48.9 | 3.2 | 2.9 | AGPL-3.0 |
| YOLO11-pose S | 57.5 | 3.4 | 9.9 | AGPL-3.0 |
| YOLO11-pose M | 64.2 | 5.2 | 20.9 | AGPL-3.0 |
| YOLO11-pose L | 65.2 | 6.6 | 26.2 | AGPL-3.0 |
| YOLO11-pose X | 68.6 | 10.6 | 58.8 | AGPL-3.0 |
| YOLO26-pose N | 55.9 | 1.9 | 2.9 | AGPL-3.0 |
| YOLO26-pose S | 62.0 | 2.7 | 10.4 | AGPL-3.0 |
| YOLO26-pose M | 68.0 | 4.6 | 21.5 | AGPL-3.0 |
| YOLO26-pose L | 69.2 | 5.9 | 25.9 | AGPL-3.0 |
| YOLO26-pose X | 71.0 | 9.8 | 57.6 | AGPL-3.0 |
Keypoint benchmarks report AP50:95 (OKS-based); this is the standard COCO keypoint comparison metric.
Roboflow 平台上的 NAS
自论文发布以来,我们已在 Roboflow 平台上进一步提升了 RF-DETR NAS 的训练。单次训练运行即可提供所有模型尺寸,其结果不仅超越了开源检查点,也超越了我们论文中的 NAS 结果。立即试用!
运行模型
检测
RF-DETR 提供多种模型尺寸,范围从 Nano 到 2XLarge。若要使用不同的模型尺寸,请将下方代码片段中的类名替换为表格中的另一个类。
import supervision as sv
from rfdetr import RFDETRMedium
from rfdetr.assets.coco_classes import COCO_CLASSES
model = RFDETRMedium()
detections = model.predict("https://media.roboflow.com/dog.jpg", threshold=0.5)
labels = [f"{COCO_CLASSES[class_id]}" for class_id in detections.class_id]
annotated_image = sv.BoxAnnotator().annotate(detections.metadata["source_image"], detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections, labels)
注意:
COCO_CLASSES适用于 COCO 预训练模型。对于微调后的模型,请改用detections.data["class_name"]—— 它从检查点中解析类别名称,同时适用于 COCO 和自定义数据集。
使用 Inference 运行 RF-DETR
你也可以使用 Inference 库运行 RF-DETR 模型。要切换模型大小,请从下表中选择相应的推理包别名。
import requests
import supervision as sv
from PIL import Image
from inference import get_model
model = get_model("rfdetr-medium")
image = Image.open(requests.get("https://media.roboflow.com/dog.jpg", stream=True).raw)
predictions = model.infer(image, confidence=0.5)[0]
detections = sv.Detections.from_inference(predictions)
annotated_image = sv.BoxAnnotator().annotate(image, detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections)
| Size | RF-DETR package class | Inference package alias | COCO AP50 | COCO AP50:95 | Latency (ms) | Params (M) | Resolution | License |
|---|---|---|---|---|---|---|---|---|
| N | RFDETRNano | rfdetr-nano | 67.6 | 48.4 | 2.3 | 30.5 | 384x384 | Apache 2.0 |
| S | RFDETRSmall | rfdetr-small | 72.1 | 53.0 | 3.5 | 32.1 | 512x512 | Apache 2.0 |
| M | RFDETRMedium | rfdetr-medium | 73.6 | 54.7 | 4.4 | 33.7 | 576x576 | Apache 2.0 |
| L | RFDETRLarge | rfdetr-large | 75.1 | 56.5 | 6.8 | 33.9 | 704x704 | Apache 2.0 |
| XL | RFDETRXLarge △ | rfdetr-xlarge | 77.4 | 58.6 | 11.5 | 126.4 | 700x700 | PML 1.0 |
| 2XL | RFDETR2XLarge △ | rfdetr-2xlarge | 78.5 | 60.1 | 17.2 | 126.9 | 880x880 | PML 1.0 |
△ 需要
rfdetr_plus扩展:pip install rfdetr[plus]。详见 License。
分割
RF-DETR 支持实例分割,模型尺寸从 Nano 到 2XLarge。若要使用不同的模型尺寸,请将下方代码片段中的类名替换为表格中的另一个类。
import supervision as sv
from rfdetr import RFDETRSegMedium
from rfdetr.assets.coco_classes import COCO_CLASSES
model = RFDETRSegMedium()
detections = model.predict("https://media.roboflow.com/dog.jpg", threshold=0.5)
labels = [f"{COCO_CLASSES[class_id]}" for class_id in detections.class_id]
annotated_image = sv.MaskAnnotator().annotate(detections.metadata["source_image"], detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections, labels)
使用推理运行 RF-DETR-Seg
您也可以使用 Inference 库运行 RF-DETR-Seg 模型。要切换模型大小,请从下表中选择相应的推理包别名。
import requests
import supervision as sv
from PIL import Image
from inference import get_model
model = get_model("rfdetr-seg-medium")
image = Image.open(requests.get("https://media.roboflow.com/dog.jpg", stream=True).raw)
predictions = model.infer(image, confidence=0.5)[0]
detections = sv.Detections.from_inference(predictions)
annotated_image = sv.MaskAnnotator().annotate(image, detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections)
| Size | RF-DETR package class | Inference package alias | COCO AP50 | COCO AP50:95 | Latency (ms) | Params (M) | Resolution | License |
|---|---|---|---|---|---|---|---|---|
| N | RFDETRSegNano | rfdetr-seg-nano | 63.0 | 40.3 | 3.4 | 33.6 | 312x312 | Apache 2.0 |
| S | RFDETRSegSmall | rfdetr-seg-small | 66.2 | 43.1 | 4.4 | 33.7 | 384x384 | Apache 2.0 |
| M | RFDETRSegMedium | rfdetr-seg-medium | 68.4 | 45.3 | 5.9 | 35.7 | 432x432 | Apache 2.0 |
| L | RFDETRSegLarge | rfdetr-seg-large | 70.5 | 47.1 | 8.8 | 36.2 | 504x504 | Apache 2.0 |
| XL | RFDETRSegXLarge | rfdetr-seg-xlarge | 72.2 | 48.8 | 13.5 | 38.1 | 624x624 | Apache 2.0 |
| 2XL | RFDETRSeg2XLarge | rfdetr-seg-2xlarge | 73.1 | 49.9 | 21.8 | 38.6 | 768x768 | Apache 2.0 |
关键点
RF-DETR 支持关键点检测(预览),使用 RFDETRKeypointPreview,在 COCO 人体关键点上预训练。
from rfdetr import RFDETRKeypointPreview
model = RFDETRKeypointPreview()
key_points = model.predict("image.jpg", threshold=0.5)
| Size | RF-DETR package class | COCO AP50:95 | Latency (ms) | Params (M) | Resolution | License |
|---|---|---|---|---|---|---|
| Keypoint (Preview) | RFDETRKeypointPreview | 71.8 | 9.7 | 40.7 | 576x576 | Apache 2.0 |
训练模型
RF-DETR 支持目标检测、实例分割和关键点检测(预览)的训练。您可以在 Google Colab 或直接在 Roboflow 平台上训练模型。下方您将找到一个逐步的视频微调教程。
文档
请访问我们的文档网站,了解更多关于如何使用 RF-DETR 的信息。
许可证
许可证按组件划分:
- 开源
rfdetr包和指定为 Apache 的模型权重采用 Apache License 2.0 许可。参见LICENSE。 - Plus 组件,包括
rfdetr_plus扩展以及 RF-DETR-XL / RF-DETR-2XL 检测模型,采用 PML 1.0 许可。
致谢
我们的工作基于 LW-DETR、DINOv2 和 Deformable DETR。感谢他们的作者们出色的工作!
引用
如果您认为我们的工作对您的研究有帮助,请考虑引用以下 BibTeX 条目。
@inproceedings{robinson2026rfdetr,
title = {RF-DETR: Real-Time Detection Transformer},
author = {Robinson, Isaac and Robicheaux, Peter and Popov, Matvei and Ramanan, Deva and Peri, Neehar},
booktitle = {International Conference on Learning Representations (ICLR)},
year = {2026},
url = {https://arxiv.org/abs/2511.09554}
}
贡献
我们欢迎并感谢所有贡献!如果您发现任何问题或错误、有疑问,或希望建议新功能,请提交 issue 或 pull request。通过分享您的想法和改进,您帮助让 RF-DETR 对每个人变得更好。