File size: 4,985 Bytes
67762b3
 
 
b34b7df
9b5436e
67762b3
 
9b5436e
b34b7df
 
 
 
67762b3
b34b7df
 
67762b3
 
5acf152
b34b7df
 
 
5acf152
b34b7df
9b5436e
b34b7df
 
 
 
 
 
 
9b5436e
67762b3
b34b7df
 
 
67762b3
 
b34b7df
 
 
 
9b5436e
b34b7df
9b5436e
 
b34b7df
 
 
 
 
 
 
 
 
 
 
67762b3
b34b7df
9b5436e
b34b7df
 
 
9b5436e
 
 
 
 
 
 
 
 
 
 
 
b34b7df
 
 
9b5436e
b34b7df
 
 
9b5436e
b34b7df
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
pipeline_tag: object-detection
license: apache-2.0
base_model: Roboflow/rf-detr-small
library_name: zeromodels
tags:
- keras
- zeromodels
- rf-detr
- detr
- object-detection
- arxiv:2511.09554
- pytorch
- jax
- tf
---

## ***See [our collection](https://huggingface.co/collections/zeromodels/rf-detr-6a8eaf8ec7324fc5f005027a) for all versions of RF-DETR.***

# Run RF-DETR with Keras 3: JAX, PyTorch, or TensorFlow

[![GitHub](https://img.shields.io/badge/GitHub-ZeroModels-black?logo=github)](https://github.com/IMvision12/ZeroModels) [![Docs](https://img.shields.io/badge/Docs-RF--DETR-blue)](https://imvision12.github.io/ZeroModels/rf_detr/) [![Collection](https://img.shields.io/badge/HF-RF--DETR%20collection-yellow)](https://huggingface.co/collections/zeromodels/rf-detr-6a8eaf8ec7324fc5f005027a)

# zeromodels/rfdetr-small

Paper: [RF-DETR: Neural Architecture Search for Real-Time Detection Transformers (arXiv:2511.09554)](https://arxiv.org/abs/2511.09554) · [HF Papers](https://huggingface.co/papers/2511.09554)

RF-DETR is Roboflow's real-time DETR, built on a windowed DINOv2 backbone with a lightweight deformable decoder. Configurations came out of a neural architecture search, so variants differ in resolution, patch size, window count, and decoder depth. Instance-segmentation checkpoints add a mask head.

For more details on the model, please go to Roboflow's original [model card](https://huggingface.co/Roboflow/rf-detr-small).

Pure-**Keras 3** conversion of [`Roboflow/rf-detr-small`](https://huggingface.co/Roboflow/rf-detr-small) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**.

This is an **object detection** checkpoint (`RFDETRDetect`): each query predicts a class and box.

## ✨ Quick start

```python
import os
os.environ["KERAS_BACKEND"] = "torch"  # or "jax" / "tensorflow"

from PIL import Image
from zeromodels.models.rf_detr import RFDETRDetect, RFDETRImageProcessor

model = RFDETRDetect.from_weights("zeromodels/rfdetr-small")
processor = RFDETRImageProcessor.from_weights("zeromodels/rfdetr-small")

image = Image.open("your_image.jpg").convert("RGB")
inputs = processor(image)
output = model(inputs["pixel_values"], training=False)
results = processor.post_process_object_detection(
    output, threshold=0.5, target_sizes=[(image.height, image.width)]
)[0]
for score, name, box in zip(
    results["scores"], results["label_names"], results["boxes"]
):
    print(f"{name}: {float(score):.3f} {box}")
```

Load any RF-DETR variant the same way with `from_weights("zeromodels/<variant>")` (use `RFDETRDetect` for this repo):

| Variant | Hub | Task |
|---|---|---|
| `rfdetr-nano` | [`zeromodels/rfdetr-nano`](https://huggingface.co/zeromodels/rfdetr-nano) | object detection |
| `rfdetr-small` | [`zeromodels/rfdetr-small`](https://huggingface.co/zeromodels/rfdetr-small) | object detection |
| `rfdetr-medium` | [`zeromodels/rfdetr-medium`](https://huggingface.co/zeromodels/rfdetr-medium) | object detection |
| `rfdetr-base` | [`zeromodels/rfdetr-base`](https://huggingface.co/zeromodels/rfdetr-base) | object detection |
| `rfdetr-large` | [`zeromodels/rfdetr-large`](https://huggingface.co/zeromodels/rfdetr-large) | object detection |
| `rfdetr-seg-preview` | [`zeromodels/rfdetr-seg-preview`](https://huggingface.co/zeromodels/rfdetr-seg-preview) | instance segmentation |
| `rfdetr-seg-nano` | [`zeromodels/rfdetr-seg-nano`](https://huggingface.co/zeromodels/rfdetr-seg-nano) | instance segmentation |
| `rfdetr-seg-small` | [`zeromodels/rfdetr-seg-small`](https://huggingface.co/zeromodels/rfdetr-seg-small) | instance segmentation |
| `rfdetr-seg-medium` | [`zeromodels/rfdetr-seg-medium`](https://huggingface.co/zeromodels/rfdetr-seg-medium) | instance segmentation |
| `rfdetr-seg-large` | [`zeromodels/rfdetr-seg-large`](https://huggingface.co/zeromodels/rfdetr-seg-large) | instance segmentation |
| `rfdetr-seg-xlarge` | [`zeromodels/rfdetr-seg-xlarge`](https://huggingface.co/zeromodels/rfdetr-seg-xlarge) | instance segmentation |
| `rfdetr-seg-xxlarge` | [`zeromodels/rfdetr-seg-xxlarge`](https://huggingface.co/zeromodels/rfdetr-seg-xxlarge) | instance segmentation |

## Tips

- Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
- Prefer `RFDETRImageProcessor.from_weights(...)` so the processor resolution matches the variant (bare constructor defaults to base's 560).
- Detection: `RFDETRDetect` + `post_process_object_detection`.
- Segmentation: `RFDETRInstanceSegment` + `post_process_instance_segmentation`.
- See [RF-DETR docs](https://imvision12.github.io/ZeroModels/rf_detr/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `RFDETRDetect.from_weights("hf:Roboflow/rf-detr-small")`.

## Special Thanks

A huge thank you to the Roboflow RF-DETR authors for creating and releasing these models.

License: Apache 2.0.