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-large")
10model = RfDetrForObjectDetection.from_pretrained("stevenbucaille/rf-detr-large")
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.99 at location [40.68, 73.34, 175.62, 118.01]
Detected cat with confidence 0.986 at location [348.33, 24.59, 640.12, 373.98]
Detected cat with confidence 0.986 at location [13.36, 54.71, 316.59, 473.24]
Detected remote with confidence 0.947 at location [334.29, 76.64, 370.47, 187.34]
Detected couch with confidence 0.549 at location [1.67, 0.92, 639.56, 474.81]
Detected remote with confidence 0.135 at location [338.6, 76.26, 369.93, 130.59]
Detected remote with confidence 0.268 at location [258.99, 54.31, 291.03, 78.72]
Detected remote with confidence 0.119 at location [335.04, 150.52, 352.63, 186.95]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}