See our collection for all versions of RT-DETR.

Run RT-DETRv2 with Keras 3: JAX, PyTorch, or TensorFlow

GitHub Docs Collection

kerasformers/rtdetr-v2-r18vd

Paper: RT-DETRv2: Improved Baseline with Bag-of-Freebies for Real-Time Detection Transformers (arXiv:2407.17140) · HF Papers

RT-DETRv2 keeps RT-DETR's hybrid encoder and deformable decoder and improves sampling: per-level offsets are merged and scaled by a learned n_points_scale, plus a refined training recipe (bag of freebies). The API matches v1; the weights are not interchangeable.

For more details on the model, please go to PekingU's original model card.

Pure-Keras 3 conversion of PekingU/rtdetr_v2_r18vd for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX.

This is an object detection checkpoint (RTDETRV2Detect) on COCO (ResNet-18-vd).

✨ Quick start

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

from PIL import Image
from kerasformers.models.rt_detr_v2 import (
    RTDETRV2Detect,
    RTDETRV2ImageProcessor,
)

model = RTDETRV2Detect.from_weights("kerasformers/rtdetr-v2-r18vd")
processor = RTDETRV2ImageProcessor()

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 RT-DETRv2 variant the same way with from_weights("kerasformers/<variant>"):

Variant Hub Backbone
rtdetr-v2-r18vd kerasformers/rtdetr-v2-r18vd ResNet-18-vd
rtdetr-v2-r34vd kerasformers/rtdetr-v2-r34vd ResNet-34-vd
rtdetr-v2-r50vd kerasformers/rtdetr-v2-r50vd ResNet-50-vd
rtdetr-v2-r101vd kerasformers/rtdetr-v2-r101vd ResNet-101-vd

Tips

  • Set KERAS_BACKEND before importing Keras / kerasformers.
  • RTDETRV2ImageProcessor keeps do_normalize=False by default (rescaled [0, 1] input, matching upstream).
  • See RT-DETRv2 docs and Loading Weights.
  • Community / upstream safetensors still work via the hf: prefix, e.g. RTDETRV2Detect.from_weights("hf:PekingU/rtdetr_v2_r18vd").

Special Thanks

A huge thank you to the RT-DETRv2 authors (Baidu / PekingU) for creating and releasing these models.

License: Apache 2.0.

Downloads last month
26
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kerasformers/rtdetr-v2-r18vd

Finetuned
(19)
this model

Collection including kerasformers/rtdetr-v2-r18vd

Paper for kerasformers/rtdetr-v2-r18vd