birder-project/d_fine_l_objects365-coco_hgnet_v2_b4_pp-imagenet22k
Model Card for dfinelobjects365-cocohgnetv2b4_pp-imagenet22k
A D-FINE large object detector with an HGNet v2 B4 backbone, pretrained on Objects365-2020 and fine-tuned on COCO 2017. Training used multi-resolution inputs sampled from 480px to 800px.
An inference-optimized, structurally reparameterized checkpoint is also provided as d_fine_l_objects365-coco_hgnet_v2_b4_pp-imagenet22k_reparameterized.
Important: The reparameterized checkpoint fuses compatible convolution and normalization branches and removes training-only decoder components. It is intended for inference and deployment. For continued training or fine-tuning, use the standard checkpoint, d_fine_l_objects365-coco_hgnet_v2_b4_pp-imagenet22k, and reparameterize the model only after training is complete.
Custom Kernels: This model uses optimized custom kernel for Deformable Attention operations. If you encounter compilation issues or prefer to use pure PyTorch implementations, set the environment variable DISABLE_CUSTOM_KERNELS=1 before loading the model.
Model Details
- Model Type: Object detection
- Model Stats:
- Params (M): 31.3
- Input image size: 640 x 640
- Dataset: COCO 2017 (80 classes)
- Papers:
- D-FINE: Redefine Regression Task in DETRs as Fine-grained Distribution Refinement: <https://arxiv.org/abs/2410.13842>
- Metrics:
Model Usage
Object Detection
import birder
from birder.inference.detection import infer_image
# Option 1: manual setup (more control over preprocessing)
net, model_info = birder.load_pretrained_model("d_fine_l_objects365-coco_hgnet_v2_b4_pp-imagenet22k", inference=True)
# Get the image size the model was trained on
size = birder.get_size_from_signature(model_info.signature)
# Create an inference transform
transform = birder.detection_transform(size, model_info.rgb_stats, dynamic_size=model_info.signature["dynamic"])
# Option 2: helper (quick start with default preprocessing)
net, model_info, transform = birder.load_pretrained_model_and_transform("d_fine_l_objects365-coco_hgnet_v2_b4_pp-imagenet22k", inference=True)
image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
detections = infer_image(net, image, transform)
# detections is a dict with keys: 'boxes', 'labels', 'scores'
# boxes: torch.Tensor with shape (N, 4) in [x1, y1, x2, y2] format
# labels: torch.Tensor with shape (N,) containing class indices
# scores: torch.Tensor with shape (N,) containing confidence scoresReparameterized Inference
Use the _reparameterized checkpoint for inference-oriented deployment. Birder automatically constructs the matching reparameterized architecture, no additional conversion flag is needed.
import birder
from birder.inference.detection import infer_image
weights = "d_fine_l_objects365-coco_hgnet_v2_b4_pp-imagenet22k_reparameterized"
net, model_info, transform = birder.load_pretrained_model_and_transform(weights, inference=True)
image = "path/to/image.jpeg" # or a PIL image, must be loaded in RGB format
detections = infer_image(net, image, transform)Citation
@misc{peng2024dfineredefineregressiontask,
title={D-FINE: Redefine Regression Task in DETRs as Fine-grained Distribution Refinement},
author={Yansong Peng and Hebei Li and Peixi Wu and Yueyi Zhang and Xiaoyan Sun and Feng Wu},
year={2024},
eprint={2410.13842},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2410.13842},
}