Instructions to use kerasformers/dfine-xlarge with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use kerasformers/dfine-xlarge 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/dfine-xlarge 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/dfine-xlarge") - Notebooks
- Google Colab
- Kaggle
See our collection for all versions of D-FINE.
Run D-FINE with Keras 3: JAX, PyTorch, or TensorFlow
kerasformers/dfine-xlarge
Paper: D-FINE: Redefine Regression Task of DETRs as Fine-grained Distribution Refinement (arXiv:2410.13842) · HF Papers
D-FINE is a real-time detector built on the RT-DETR recipe: an HGNetV2 backbone, a hybrid encoder, and a deformable decoder with 300 queries. It is NMS-free. Boxes are regressed via Fine-grained Distribution Refinement: each decoder layer predicts a distribution over discrete offset bins and accumulates refinements across layers.
For more details on the model, please go to the upstream model card.
Pure-Keras 3 conversion of ustc-community/dfine-xlarge-coco for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX.
This is an object detection checkpoint (DFineDetect) on COCO (HGNetV2-XLarge).
✨ Quick start
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from PIL import Image
from kerasformers.models.dfine import DFineDetect, DFineImageProcessor
model = DFineDetect.from_weights("kerasformers/dfine-xlarge")
processor = DFineImageProcessor.from_weights("kerasformers/dfine-xlarge")
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 D-FINE variant the same way with from_weights("kerasformers/<variant>"):
| Variant | Hub | Backbone |
|---|---|---|
dfine-nano |
kerasformers/dfine-nano |
HGNetV2-Nano |
dfine-small |
kerasformers/dfine-small |
HGNetV2-Small |
dfine-medium |
kerasformers/dfine-medium |
HGNetV2-Medium |
dfine-large |
kerasformers/dfine-large |
HGNetV2-Large |
dfine-xlarge |
kerasformers/dfine-xlarge |
HGNetV2-XLarge |
Tips
- Set
KERAS_BACKENDbefore importing Keras / kerasformers. DFineImageProcessorkeepsdo_normalize=Falseby default (rescaled[0, 1]input, matching upstream).- See D-FINE docs and Loading Weights.
- Community / upstream safetensors still work via the
hf:prefix, e.g.DFineDetect.from_weights("hf:ustc-community/dfine-xlarge-coco").
Special Thanks
A huge thank you to the D-FINE authors (USTC community) for creating and releasing these models.
License: Apache 2.0.
- Downloads last month
- 21
Model tree for kerasformers/dfine-xlarge
Base model
ustc-community/dfine-xlarge-coco