CoolFace
Modelpublic

justjuu/rtdetr-v2-license-plate-detection

sourceHugging Faceapache-2.0updated 8mo agoView on Hugging Face
3likes1.1kdownloads
Model Card

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.

SplitNumber of Images
Train6,176
Validation1,765
Test882

Performance & Evaluation

The model is evaluated using the COCO-style Mean Average Precision (mAP) metrics on the test split (882 images).

MetricScore
mAP (0.5:0.95)0.97
mAP @ 0.500.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:

python
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}")