RT-DETR v2 for License Plate Detection
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.
Model Details
- Model Architecture: RT-DETR v2 (Efficient hybrid encoder-decoder transformer)
- Task: Object Detection (License Plates)
- Base Model:
PekingU/rtdetr_v2 - Dataset:
justjuu/license-plate-detection - Fine-tuning Framework: Hugging Face Transformers & PyTorch
Dataset
The 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 |
Performance & Evaluation
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 |
Training Configuration
The model was fine-tuned with the following hyperparameters (extracted from the training notebook):
- Learning Rate:
1e-4 - Batch Size:
12 - Epochs:
3 - Weight Decay:
1e-4 - Optimizer:
AdamW - Hardware: T4 GPU (Google Colab)
Usage
Inference with Hugging Face Transformers
You 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}")
- Downloads last month
- 570
Model tree for justjuu/rtdetr-v2-license-plate-detection
Base model
PekingU/rtdetr_v2_r50vd