merve HF Staff commited on
Commit
39d2ef8
·
0 Parent(s):

Initial commit

Browse files
Files changed (5) hide show
  1. .gitattributes +35 -0
  2. README.md +94 -0
  3. config.json +285 -0
  4. model.safetensors +3 -0
  5. preprocessor_config.json +26 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - object-detection
5
+ - vision
6
+ datasets:
7
+ - coco
8
+ pipeline_tag: object-detection
9
+ library_name: transformers
10
+ ---
11
+
12
+ # RF-DETR (Base 2)
13
+
14
+ RF-DETR is a real-time detection transformer family introduced in [RF-DETR: Neural Architecture Search for Real-Time Detection Transformers](https://huggingface.co/papers/2511.09554) by Robinson et al. and integrated in 🤗 Transformers via [PR #36895](https://github.com/huggingface/transformers/pull/36895).
15
+
16
+ ## Model description
17
+
18
+ RF-DETR is an end-to-end object detection model that combines ideas from LW-DETR and Deformable DETR: a DINOv2-with-registers style ViT backbone (with an RF-DETR windowing pattern for efficient attention), a multi-scale projector between encoder and decoder, and a multi-scale deformable DETR decoder for fast convergence and strong accuracy–latency tradeoffs.
19
+
20
+ Key Architectural Details:
21
+ - **Backbone:** DINOv2-with-registers style ViT with RF-DETR **windowed / full** attention alternation (instead of a purely convolutional encoder).
22
+ - **Multi-scale fusion:** **RF-DETR multi-scale projector** (C2f-style blocks in the LW-DETR lineage) to aggregate multi-level backbone features before the decoder.
23
+ - **Decoder:** **Deformable DETR**-style decoder with multi-scale deformable cross-attention; depth and input resolution vary by checkpoint (NAS frontier).
24
+ - **Queries:** DETR-style object queries with bipartite matching and auxiliary decoder losses for training stability.
25
+
26
+ Training Details:
27
+ - **Detection losses:** classification plus bounding-box L1 and GIoU, with auxiliary losses on intermediate decoder layers.
28
+ - **Group DETR:** parallel decoder copies during training for faster convergence (same high-level idea as LW-DETR's Group DETR).
29
+ - **NAS (family-level):** the RF-DETR paper uses weight-sharing neural architecture search over practical accuracy–latency knobs after adapting a shared backbone on the target dataset, so many checkpoints correspond to different subnets without full independent retrains for every point on the frontier.
30
+
31
+ ### How to use
32
+
33
+ You can use the raw model for object detection. See the [model hub](https://huggingface.co/models?search=stevenbucaille/rf-detr) to look for all available RF-DETR models.
34
+
35
+ Here is how to use this model:
36
+
37
+ ```python
38
+ from transformers import AutoImageProcessor, RfDetrForObjectDetection
39
+ import torch
40
+ from PIL import Image
41
+ import requests
42
+
43
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
44
+ image = Image.open(requests.get(url, stream=True).raw)
45
+
46
+ processor = AutoImageProcessor.from_pretrained("stevenbucaille/rf-detr-base-2")
47
+ model = RfDetrForObjectDetection.from_pretrained("stevenbucaille/rf-detr-base-2")
48
+
49
+ inputs = processor(images=image, return_tensors="pt")
50
+ outputs = model(**inputs)
51
+
52
+ # convert outputs (bounding boxes and class logits) to COCO API
53
+ # let's only keep detections with score > 0.35
54
+ target_sizes = torch.tensor([image.size[::-1]])
55
+ results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.35)[0]
56
+
57
+ for score, label, box in list(zip(results["scores"], results["labels"], results["boxes"]))[:8]:
58
+ box = [round(i, 2) for i in box.tolist()]
59
+ print(
60
+ f"Detected {model.config.id2label[label.item()]} with confidence "
61
+ f"{round(score.item(), 3)} at location {box}"
62
+ )
63
+ ```
64
+ This should output:
65
+ ```
66
+ Detected remote with confidence 0.981 at location [40.78, 72.72, 175.68, 117.19]
67
+ Detected cat with confidence 0.979 at location [7.45, 54.47, 316.23, 473.51]
68
+ Detected cat with confidence 0.964 at location [343.26, 23.5, 636.68, 371.82]
69
+ Detected remote with confidence 0.821 at location [333.94, 77.32, 370.25, 186.78]
70
+ Detected couch with confidence 0.446 at location [0.62, 1.44, 639.34, 475.39]
71
+ Detected chair with confidence 0.113 at location [2.55, 1.5, 640.67, 476.14]
72
+ Detected bed with confidence 0.165 at location [5.88, 116.99, 638.36, 472.72]
73
+ Detected couch with confidence 0.183 at location [0.57, 1.34, 639.31, 271.61]
74
+ ```
75
+
76
+ ## Training data
77
+
78
+ These checkpoints are trained on the standard [COCO 2017 object detection dataset](https://cocodataset.org/#home) label space (80 categories) as reflected in `config.id2label`.
79
+
80
+ ### BibTeX entry and citation info
81
+
82
+ ```bibtex
83
+ @misc{robinson2026rfdetrneuralarchitecturesearch,
84
+ title={RF-DETR: Neural Architecture Search for Real-Time Detection Transformers},
85
+ author={Isaac Robinson and Peter Robicheaux and Matvei Popov and Deva Ramanan and Neehar Peri},
86
+ year={2026},
87
+ eprint={2511.09554},
88
+ archivePrefix={arXiv},
89
+ primaryClass={cs.CV},
90
+ url={https://huggingface.co/papers/2511.09554},
91
+ }
92
+ ```
93
+
94
+ This model was originally contributed by stevenbucaille in 🤗 transformers.
config.json ADDED
@@ -0,0 +1,285 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_dropout": 0.0,
3
+ "activation_function": "silu",
4
+ "architectures": [
5
+ "RfDetrForObjectDetection"
6
+ ],
7
+ "attention_bias": true,
8
+ "attention_dropout": 0.0,
9
+ "auxiliary_loss": true,
10
+ "backbone_config": {
11
+ "apply_layernorm": true,
12
+ "attention_probs_dropout_prob": 0.0,
13
+ "drop_path_rate": 0.0,
14
+ "dtype": "float32",
15
+ "hidden_act": "gelu",
16
+ "hidden_dropout_prob": 0.0,
17
+ "hidden_size": 384,
18
+ "image_size": 518,
19
+ "initializer_range": 0.02,
20
+ "layer_norm_eps": 1e-06,
21
+ "layerscale_value": 1.0,
22
+ "mlp_ratio": 4,
23
+ "model_type": "rf_detr_dinov2",
24
+ "num_attention_heads": 6,
25
+ "num_channels": 3,
26
+ "num_hidden_layers": 12,
27
+ "num_windows": 4,
28
+ "out_features": [
29
+ "stage2",
30
+ "stage5",
31
+ "stage8",
32
+ "stage11"
33
+ ],
34
+ "out_indices": [
35
+ 2,
36
+ 5,
37
+ 8,
38
+ 11
39
+ ],
40
+ "patch_size": 14,
41
+ "qkv_bias": true,
42
+ "reshape_hidden_states": true,
43
+ "stage_names": [
44
+ "stem",
45
+ "stage1",
46
+ "stage2",
47
+ "stage3",
48
+ "stage4",
49
+ "stage5",
50
+ "stage6",
51
+ "stage7",
52
+ "stage8",
53
+ "stage9",
54
+ "stage10",
55
+ "stage11",
56
+ "stage12"
57
+ ],
58
+ "use_mask_token": true,
59
+ "use_swiglu_ffn": false,
60
+ "window_block_indexes": [
61
+ 0,
62
+ 1,
63
+ 3,
64
+ 4,
65
+ 6,
66
+ 7,
67
+ 9,
68
+ 10
69
+ ]
70
+ },
71
+ "bbox_cost": 5,
72
+ "bbox_loss_coefficient": 5,
73
+ "c2f_num_blocks": 3,
74
+ "class_cost": 2,
75
+ "class_loss_coefficient": 1,
76
+ "d_model": 256,
77
+ "decoder_activation_function": "relu",
78
+ "decoder_cross_attention_heads": 16,
79
+ "decoder_ffn_dim": 2048,
80
+ "decoder_layers": 3,
81
+ "decoder_n_points": 2,
82
+ "decoder_self_attention_heads": 8,
83
+ "dice_loss_coefficient": 1,
84
+ "disable_custom_kernels": true,
85
+ "dropout": 0.1,
86
+ "dtype": "float32",
87
+ "eos_coefficient": 0.1,
88
+ "focal_alpha": 0.25,
89
+ "giou_cost": 2,
90
+ "giou_loss_coefficient": 2,
91
+ "group_detr": 13,
92
+ "hidden_expansion": 0.5,
93
+ "id2label": {
94
+ "0": "N/A",
95
+ "1": "person",
96
+ "2": "bicycle",
97
+ "3": "car",
98
+ "4": "motorcycle",
99
+ "5": "airplane",
100
+ "6": "bus",
101
+ "7": "train",
102
+ "8": "truck",
103
+ "9": "boat",
104
+ "10": "traffic light",
105
+ "11": "fire hydrant",
106
+ "12": "N/A",
107
+ "13": "stop sign",
108
+ "14": "parking meter",
109
+ "15": "bench",
110
+ "16": "bird",
111
+ "17": "cat",
112
+ "18": "dog",
113
+ "19": "horse",
114
+ "20": "sheep",
115
+ "21": "cow",
116
+ "22": "elephant",
117
+ "23": "bear",
118
+ "24": "zebra",
119
+ "25": "giraffe",
120
+ "26": "N/A",
121
+ "27": "backpack",
122
+ "28": "umbrella",
123
+ "29": "N/A",
124
+ "30": "N/A",
125
+ "31": "handbag",
126
+ "32": "tie",
127
+ "33": "suitcase",
128
+ "34": "frisbee",
129
+ "35": "skis",
130
+ "36": "snowboard",
131
+ "37": "sports ball",
132
+ "38": "kite",
133
+ "39": "baseball bat",
134
+ "40": "baseball glove",
135
+ "41": "skateboard",
136
+ "42": "surfboard",
137
+ "43": "tennis racket",
138
+ "44": "bottle",
139
+ "45": "N/A",
140
+ "46": "wine glass",
141
+ "47": "cup",
142
+ "48": "fork",
143
+ "49": "knife",
144
+ "50": "spoon",
145
+ "51": "bowl",
146
+ "52": "banana",
147
+ "53": "apple",
148
+ "54": "sandwich",
149
+ "55": "orange",
150
+ "56": "broccoli",
151
+ "57": "carrot",
152
+ "58": "hot dog",
153
+ "59": "pizza",
154
+ "60": "donut",
155
+ "61": "cake",
156
+ "62": "chair",
157
+ "63": "couch",
158
+ "64": "potted plant",
159
+ "65": "bed",
160
+ "66": "N/A",
161
+ "67": "dining table",
162
+ "68": "N/A",
163
+ "69": "N/A",
164
+ "70": "toilet",
165
+ "71": "N/A",
166
+ "72": "tv",
167
+ "73": "laptop",
168
+ "74": "mouse",
169
+ "75": "remote",
170
+ "76": "keyboard",
171
+ "77": "cell phone",
172
+ "78": "microwave",
173
+ "79": "oven",
174
+ "80": "toaster",
175
+ "81": "sink",
176
+ "82": "refrigerator",
177
+ "83": "N/A",
178
+ "84": "book",
179
+ "85": "clock",
180
+ "86": "vase",
181
+ "87": "scissors",
182
+ "88": "teddy bear",
183
+ "89": "hair drier",
184
+ "90": "toothbrush"
185
+ },
186
+ "init_std": 0.02,
187
+ "intermediate_size": 1024,
188
+ "label2id": {
189
+ "N/A": 83,
190
+ "airplane": 5,
191
+ "apple": 53,
192
+ "backpack": 27,
193
+ "banana": 52,
194
+ "baseball bat": 39,
195
+ "baseball glove": 40,
196
+ "bear": 23,
197
+ "bed": 65,
198
+ "bench": 15,
199
+ "bicycle": 2,
200
+ "bird": 16,
201
+ "boat": 9,
202
+ "book": 84,
203
+ "bottle": 44,
204
+ "bowl": 51,
205
+ "broccoli": 56,
206
+ "bus": 6,
207
+ "cake": 61,
208
+ "car": 3,
209
+ "carrot": 57,
210
+ "cat": 17,
211
+ "cell phone": 77,
212
+ "chair": 62,
213
+ "clock": 85,
214
+ "couch": 63,
215
+ "cow": 21,
216
+ "cup": 47,
217
+ "dining table": 67,
218
+ "dog": 18,
219
+ "donut": 60,
220
+ "elephant": 22,
221
+ "fire hydrant": 11,
222
+ "fork": 48,
223
+ "frisbee": 34,
224
+ "giraffe": 25,
225
+ "hair drier": 89,
226
+ "handbag": 31,
227
+ "horse": 19,
228
+ "hot dog": 58,
229
+ "keyboard": 76,
230
+ "kite": 38,
231
+ "knife": 49,
232
+ "laptop": 73,
233
+ "microwave": 78,
234
+ "motorcycle": 4,
235
+ "mouse": 74,
236
+ "orange": 55,
237
+ "oven": 79,
238
+ "parking meter": 14,
239
+ "person": 1,
240
+ "pizza": 59,
241
+ "potted plant": 64,
242
+ "refrigerator": 82,
243
+ "remote": 75,
244
+ "sandwich": 54,
245
+ "scissors": 87,
246
+ "sheep": 20,
247
+ "sink": 81,
248
+ "skateboard": 41,
249
+ "skis": 35,
250
+ "snowboard": 36,
251
+ "spoon": 50,
252
+ "sports ball": 37,
253
+ "stop sign": 13,
254
+ "suitcase": 33,
255
+ "surfboard": 42,
256
+ "teddy bear": 88,
257
+ "tennis racket": 43,
258
+ "tie": 32,
259
+ "toaster": 80,
260
+ "toilet": 70,
261
+ "toothbrush": 90,
262
+ "traffic light": 10,
263
+ "train": 7,
264
+ "truck": 8,
265
+ "tv": 72,
266
+ "umbrella": 28,
267
+ "vase": 86,
268
+ "wine glass": 46,
269
+ "zebra": 24
270
+ },
271
+ "layer_norm_eps": 1e-05,
272
+ "mask_class_loss_coefficient": 5.0,
273
+ "mask_dice_loss_coefficient": 5.0,
274
+ "mask_downsample_ratio": 4,
275
+ "mask_loss_coefficient": 1,
276
+ "mask_point_sample_ratio": 16,
277
+ "model_type": "rf_detr",
278
+ "num_feature_levels": 1,
279
+ "num_queries": 300,
280
+ "projector_scale_factors": [
281
+ 1.0
282
+ ],
283
+ "segmentation_head_activation_function": "gelu",
284
+ "transformers_version": "5.8.0.dev0"
285
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d84a769cbbe85f8be86702fb6c27ef26d679606dac384736d879e6cbf968bea4
3
+ size 128757944
preprocessor_config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_annotations": true,
3
+ "do_normalize": true,
4
+ "do_pad": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "format": "coco_detection",
8
+ "image_mean": [
9
+ 0.485,
10
+ 0.456,
11
+ 0.406
12
+ ],
13
+ "image_processor_type": "DetrImageProcessor",
14
+ "image_std": [
15
+ 0.229,
16
+ 0.224,
17
+ 0.225
18
+ ],
19
+ "resample": 2,
20
+ "rescale_factor": 0.00392156862745098,
21
+ "size": {
22
+ "height": 560,
23
+ "width": 560
24
+ },
25
+ "use_fast": true
26
+ }