CoolFace
Modelpublic

ustc-community/dfine-xlarge-obj365

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
5likes2kdownloads
README.md73 linesDownload Raw Back to root
1---2library_name: transformers3license: apache-2.04language:5  - en6pipeline_tag: object-detection7tags:8  - object-detection9  - vision10datasets:11  - coco12  - objects36513---14## D-FINE15 16### **Overview**17 18The D-FINE model was proposed in [D-FINE: Redefine Regression Task in DETRs as Fine-grained Distribution Refinement](https://arxiv.org/abs/2410.13842) by19Yansong Peng, Hebei Li, Peixi Wu, Yueyi Zhang, Xiaoyan Sun, Feng Wu20 21This model was contributed by [VladOS95-cyber](https://github.com/VladOS95-cyber) with the help of [@qubvel-hf](https://huggingface.co/qubvel-hf)22 23This is the HF transformers implementation for D-FINE24 25_coco -> model trained on COCO26 27_obj365 -> model trained on Object36528 29_obj2coco -> model trained on Object365 and then finetuned on COCO30 31### **Performance**32 33D-FINE, a powerful real-time object detector that achieves outstanding localization precision by redefining the bounding box regression task in DETR models. D-FINE comprises two key components: Fine-grained Distribution Refinement (FDR) and Global Optimal Localization Self-Distillation (GO-LSD). 34 35![COCO365.png](https://huggingface.co/datasets/vladislavbro/images/resolve/main/COCO365.PNG)36 37![COCO365-2.png](https://huggingface.co/datasets/vladislavbro/images/resolve/main/COCO365-2.PNG)38 39### **How to use**40 41```python42import torch43import requests44 45from PIL import Image46from transformers import DFineForObjectDetection, AutoImageProcessor47 48url = 'http://images.cocodataset.org/val2017/000000039769.jpg'49image = Image.open(requests.get(url, stream=True).raw)50 51image_processor = AutoImageProcessor.from_pretrained("ustc-community/dfine-xlarge-obj365")52model = DFineForObjectDetection.from_pretrained("ustc-community/dfine-xlarge-obj365")53 54inputs = image_processor(images=image, return_tensors="pt")55 56with torch.no_grad():57    outputs = model(**inputs)58 59results = image_processor.post_process_object_detection(outputs, target_sizes=torch.tensor([image.size[::-1]]), threshold=0.3)60 61for result in results:62    for score, label_id, box in zip(result["scores"], result["labels"], result["boxes"]):63        score, label = score.item(), label_id.item()64        box = [round(i, 2) for i in box.tolist()]65        print(f"{model.config.id2label[label]}: {score:.2f} {box}")66```67 68### **Training**69 70D-FINE is trained on COCO and Objects365 (Lin et al. [2014]) train2017 and validated on COCO + Objects365 val2017 dataset. We report the standard AP metrics (averaged over uniformly sampled IoU thresholds ranging from 0.50 − 0.95 with a step size of 0.05), and APval5000 commonly used in real scenarios.71 72### **Applications**73D-FINE is ideal for real-time object detection in diverse applications such as **autonomous driving**, **surveillance systems**, **robotics**, and **retail analytics**. Its enhanced flexibility and deployment-friendly design make it suitable for both edge devices and large-scale systems + ensures high accuracy and speed in dynamic, real-world environments.