Views
No views yet
Roboflow/rf-detr-medium for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.RFDETRDetect): each query predicts a class and box.1import os
2os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
3
4from PIL import Image
5from zeromodels.models.rf_detr import RFDETRDetect, RFDETRImageProcessor
6
7model = RFDETRDetect.from_weights("zeromodels/rfdetr-medium")
8processor = RFDETRImageProcessor.from_weights("zeromodels/rfdetr-medium")
9
10image = Image.open("your_image.jpg").convert("RGB")
11inputs = processor(image)
12output = model(inputs["pixel_values"], training=False)
13results = processor.post_process_object_detection(
14 output, threshold=0.5, target_sizes=[(image.height, image.width)]
15)[0]
16for score, name, box in zip(
17 results["scores"], results["label_names"], results["boxes"]
18):
19 print(f"{name}: {float(score):.3f} {box}")from_weights("zeromodels/<variant>") (use RFDETRDetect for this repo):| Variant | Hub | Task |
|---|---|---|
rfdetr-nano | zeromodels/rfdetr-nano | object detection |
rfdetr-small | zeromodels/rfdetr-small | object detection |
rfdetr-medium | zeromodels/rfdetr-medium | object detection |
rfdetr-base | zeromodels/rfdetr-base | object detection |
rfdetr-large | zeromodels/rfdetr-large | object detection |
rfdetr-seg-preview | zeromodels/rfdetr-seg-preview | instance segmentation |
rfdetr-seg-nano | zeromodels/rfdetr-seg-nano | instance segmentation |
rfdetr-seg-small | zeromodels/rfdetr-seg-small | instance segmentation |
rfdetr-seg-medium | zeromodels/rfdetr-seg-medium | instance segmentation |
rfdetr-seg-large | zeromodels/rfdetr-seg-large | instance segmentation |
rfdetr-seg-xlarge | zeromodels/rfdetr-seg-xlarge | instance segmentation |
rfdetr-seg-xxlarge | zeromodels/rfdetr-seg-xxlarge | instance segmentation |
KERAS_BACKEND before importing Keras / zeromodels.RFDETRImageProcessor.from_weights(...) so the processor resolution matches the variant (bare constructor defaults to base's 560).RFDETRDetect + post_process_object_detection.RFDETRInstanceSegment + post_process_instance_segmentation.hf: prefix, e.g. RFDETRDetect.from_weights("hf:Roboflow/rf-detr-medium").