Instructions to use kerasformers/rtdetr-v2-r18vd with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use kerasformers/rtdetr-v2-r18vd with KerasFormers:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Keras
How to use kerasformers/rtdetr-v2-r18vd with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://kerasformers/rtdetr-v2-r18vd") - Notebooks
- Google Colab
- Kaggle
See our collection for all versions of RT-DETR.
Run RT-DETRv2 with Keras 3: JAX, PyTorch, or TensorFlow
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_BACKENDbefore importing Keras / kerasformers. RTDETRV2ImageProcessorkeepsdo_normalize=Falseby 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
Model tree for kerasformers/rtdetr-v2-r18vd
Base model
PekingU/rtdetr_v2_r18vd