language: ru
tags:
- object-detection
- pytorch-lightning
- russian-license-plates
- rt-detr
datasets:
- testcarplate/russian-license-plates-classification-by-this-type
metrics:
- map
pipeline_tag: object-detection
---
# RT-DETR Russian car plate detection with classification by type
This model was fine-tuned on Russian license plates dataset using PyTorch Lightning.
## Training metrics:
- Final training loss: 1.7576
- Final validation mAP: 0.8979
## Model description
- Base model: PekingU/rtdetr_r50vd_coco_o365
- Training epochs: 19
- Dataset: Russian License Plates with type classification
## Usage
```python
from transformers import AutoModelForObjectDetection, AutoImageProcessor
import torch
import supervision as sv
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = AutoModelForObjectDetection.from_pretrained('Garon16/rtdetr_r50vd_russia_plate_detector').to(DEVICE)
processor = AutoImageProcessor.from_pretrained('Garon16/rtdetr_r50vd_russia_plate_detector')
path = 'path/to/image'
image = Image.open(path)
inputs = processor(image, return_tensors="pt").to(DEVICE)
with torch.no_grad():
outputs = model(**inputs)
w, h = image.size
results = processor.post_process_object_detection(
outputs, target_sizes=[(h, w)], threshold=0.3)
detections = sv.Detections.from_transformers(results[0]).with_nms(0.3)
labels = [
model.config.id2label[class_id]
for class_id
in detections.class_id
]
annotated_image = image.copy()
annotated_image = sv.BoundingBoxAnnotator().annotate(annotated_image, detections)
annotated_image = sv.LabelAnnotator().annotate(annotated_image, detections, labels=labels)
grid = sv.create_tiles(
[annotated_image],
grid_size=(1, 1),
single_tile_size=(512, 512),
tile_padding_color=sv.Color.WHITE,
tile_margin_color=sv.Color.WHITE
)
sv.plot_image(grid, size=(10, 10))
```
## Training details
The model was trained using PyTorch Lightning with the following configuration:
- Batch size: 16
- Learning rate: 5e-05
- Optimizer: AdamW
- Training device: <pytorch_lightning.accelerators.cuda.CUDAAccelerator object at 0x7edd6233bf50>
- Number of GPUs: 1
## Limitations and bias
This model is specifically trained on Russian license plates and may not perform well on license plates from other countries.
## Author
[Garon16](https://huggingface.co/Garon16)