CoolFace
Modelpublic

birder-project/d_fine_l_objects365-coco_hgnet_v2_b4_pp-imagenet22k

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
1likes168downloads
Model Card

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:
Input sizemAPmAP (reparam.)mAP@50mAP@50 (reparam.)mAP@75mAP@75 (reparam.)
512 x 51254.0053.9971.8571.8458.6458.64
576 x 57655.4755.4973.0773.0860.3160.32
608 x 60855.7755.7773.3473.3760.8160.79
640 x 64056.0956.0873.5173.5160.9860.97
672 x 67256.2156.2173.5673.5661.2161.21
704 x 70456.4356.4373.8773.8761.5461.53

Model Usage

Object Detection

python
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 scores

Reparameterized Inference

Use the _reparameterized checkpoint for inference-oriented deployment. Birder automatically constructs the matching reparameterized architecture, no additional conversion flag is needed.

python
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

bibtex
@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},
}