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-small-coco for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.
This is an object detection checkpoint (DFineDetect) on COCO (HGNetV2-Small).
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from PIL import Image
from zeromodels.models.dfine import DFineDetect, DFineImageProcessor
model = DFineDetect.from_weights("zeromodels/dfine-small")
processor = DFineImageProcessor.from_weights("zeromodels/dfine-small")
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("zeromodels/<variant>"):
| Variant | Hub | Backbone |
|---|---|---|
dfine-nano |
zeromodels/dfine-nano |
HGNetV2-Nano |
dfine-small |
zeromodels/dfine-small |
HGNetV2-Small |
dfine-medium |
zeromodels/dfine-medium |
HGNetV2-Medium |
dfine-large |
zeromodels/dfine-large |
HGNetV2-Large |
dfine-xlarge |
zeromodels/dfine-xlarge |
HGNetV2-XLarge |
KERAS_BACKEND before importing Keras / zeromodels.DFineImageProcessor keeps do_normalize=False by default (rescaled [0, 1] input, matching upstream).hf: prefix, e.g. DFineDetect.from_weights("hf:ustc-community/dfine-small-coco").A huge thank you to the D-FINE authors (USTC community) for creating and releasing these models.
License: Apache 2.0.
Have the files? Publish a torrent.
Publish a torrentHave the complete files and permission to share them? Replace the example folder path. The script checks the files, makes a torrent and submits its magnet and checksums. Keep your torrent client seeding. Get your community key from your settings, and read the script before running it.
curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo zeromodels/dfine-small ./model-folderustc-community/dfine-small-coco