Instructions to use ustc-community/dfine-small-obj365 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ustc-community/dfine-small-obj365 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("object-detection", model="ustc-community/dfine-small-obj365")# Load model directly from transformers import AutoTokenizer, AutoModelForObjectDetection tokenizer = AutoTokenizer.from_pretrained("ustc-community/dfine-small-obj365") model = AutoModelForObjectDetection.from_pretrained("ustc-community/dfine-small-obj365", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 1,367 Bytes
b8e7430 2bf2312 b8e7430 2bf2312 b8e7430 2bf2312 b8e7430 2bf2312 b8e7430 2bf2312 b8e7430 2bf2312 b8e7430 2bf2312 b8e7430 2bf2312 b8e7430 2bf2312 b8e7430 2bf2312 b8e7430 2bf2312 b8e7430 2bf2312 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | ---
library_name: transformers
---
This is the HF transformers implementation for D-FINE
Model: D-FINE-S-OBJ365-COCO
D-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).
Usage:
```python
import torch
import requests
from PIL import Image
from transformers import DFineForObjectDetection, AutoImageProcessor
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
image_processor = AutoImageProcessor.from_pretrained("vladislavbro/dfine_s_obj365")
model = DFineForObjectDetection.from_pretrained("vladislavbro/dfine_s_obj365")
inputs = image_processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
results = image_processor.post_process_object_detection(outputs, target_sizes=torch.tensor([image.size[::-1]]), threshold=0.3)
for result in results:
for score, label_id, box in zip(result["scores"], result["labels"], result["boxes"]):
score, label = score.item(), label_id.item()
box = [round(i, 2) for i in box.tolist()]
print(f"{model.config.id2label[label]}: {score:.2f} {box}") |