Views
No views yet
1from transformers import AutoImageProcessor, RfDetrForObjectDetection
2import torch
3from PIL import Image
4import requests
5
6url = "http://images.cocodataset.org/val2017/000000039769.jpg"
7image = Image.open(requests.get(url, stream=True).raw)
8
9processor = AutoImageProcessor.from_pretrained("stevenbucaille/rf-detr-base-2")
10model = RfDetrForObjectDetection.from_pretrained("stevenbucaille/rf-detr-base-2")
11
12inputs = processor(images=image, return_tensors="pt")
13outputs = model(**inputs)
14
15# convert outputs (bounding boxes and class logits) to COCO API
16# let's only keep detections with score > 0.35
17target_sizes = torch.tensor([image.size[::-1]])
18results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.35)[0]
19
20for score, label, box in list(zip(results["scores"], results["labels"], results["boxes"]))[:8]:
21 box = [round(i, 2) for i in box.tolist()]
22 print(
23 f"Detected {model.config.id2label[label.item()]} with confidence "
24 f"{round(score.item(), 3)} at location {box}"
25 )Detected remote with confidence 0.981 at location [40.78, 72.72, 175.68, 117.19]
Detected cat with confidence 0.979 at location [7.45, 54.47, 316.23, 473.51]
Detected cat with confidence 0.964 at location [343.26, 23.5, 636.68, 371.82]
Detected remote with confidence 0.821 at location [333.94, 77.32, 370.25, 186.78]
Detected couch with confidence 0.446 at location [0.62, 1.44, 639.34, 475.39]
Detected chair with confidence 0.113 at location [2.55, 1.5, 640.67, 476.14]
Detected bed with confidence 0.165 at location [5.88, 116.99, 638.36, 472.72]
Detected couch with confidence 0.183 at location [0.57, 1.34, 639.31, 271.61]config.id2label.1@misc{robinson2026rfdetrneuralarchitecturesearch,
2 title={RF-DETR: Neural Architecture Search for Real-Time Detection Transformers},
3 author={Isaac Robinson and Peter Robicheaux and Matvei Popov and Deva Ramanan and Neehar Peri},
4 year={2026},
5 eprint={2511.09554},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://huggingface.co/papers/2511.09554},
9}