justjuu/license-plate-detection
Viewer β’ Updated β’ 8.82k β’ 153 β’ 2
How to use justjuu/rtdetr-v2-license-plate-detection with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("object-detection", model="justjuu/rtdetr-v2-license-plate-detection") # Load model directly
from transformers import AutoTokenizer, AutoModelForObjectDetection
tokenizer = AutoTokenizer.from_pretrained("justjuu/rtdetr-v2-license-plate-detection")
model = AutoModelForObjectDetection.from_pretrained("justjuu/rtdetr-v2-license-plate-detection", device_map="auto")This model is a fine-tuned version of RT-DETR v2 (Real-Time DEtection TRansformer) optimized for the task of detecting license plates in vehicles. It was trained on the justjuu/license-plate-detection dataset.
PekingU/rtdetr_v2justjuu/license-plate-detectionThe model was trained on a diverse collection of vehicle images annotated with license plate bounding boxes.
| Split | Number of Images |
|---|---|
| Train | 6,176 |
| Validation | 1,765 |
| Test | 882 |
The model is evaluated using the COCO-style Mean Average Precision (mAP) metrics on the test split (882 images).
| Metric | Score |
|---|---|
| mAP (0.5:0.95) | 0.97 |
| mAP @ 0.50 | 0.97 |
| mAP (Small) | 0.88 |
| mAP (Medium) | 0.99 |
| mAP (Large) | 1 |
The model was fine-tuned with the following hyperparameters (extracted from the training notebook):
1e-41231e-4AdamWYou can use this model to detect license plates in images using the Python code below:
from transformers import AutoImageProcessor, AutoModelForObjectDetection
import torch
from PIL import Image
import requests
# 1. Load Image
url = "[https://example.com/car-image.jpg](https://example.com/car-image.jpg)" # Replace with your image URL or path
image = Image.open(requests.get(url, stream=True).raw)
# 2. Load Model and Processor
model_id = "justjuu/rtdetr-v2-license-plate-detection"
processor = AutoImageProcessor.from_pretrained(model_id)
model = AutoModelForObjectDetection.from_pretrained(model_id)
# 3. Process Input
inputs = processor(images=image, return_tensors="pt")
# 4. Inference
with torch.no_grad():
outputs = model(**inputs)
# 5. Post-process (Non-Maximum Suppression is effectively handled by the DETR architecture, but we define thresholds)
target_sizes = torch.tensor([image.size[::-1]])
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.5)[0]
# 6. Print Results
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
box = [round(i, 2) for i in box.tolist()]
print(f"Detected {model.config.id2label[label.item()]} with confidence {round(score.item(), 3)} at location {box}")
Base model
PekingU/rtdetr_v2_r50vd