base_model: microsoft/trocr-base-handwritten
tags:
- trocr
- image-to-text
- license-plate-number
model-index:
- name: license_plate_recognizer
results:
- task:
type: image-to-text
name: License Plate Recognition
dataset:
type: custom_dataset
name: Custom License Plate Dataset
config: default
split: test
revision: main
metrics:
- type: cer
value: 0.0231
name: Test CER
config: default
args:
max_order: 4
source:
name: Hugging Face Model Card
url: https://huggingface.co/PawanKrGunjan/license_plate_recognizer
license: mit
language:
- en
metrics:
- cer
library_name: transformers
pipeline_tag: image-to-text
datasets:
- charliexu07/license_plates
license_plate_recognizer
This model is a fine-tuned version of microsoft/trocr-base-handwritten specifically tailored for recognizing license plate numbers from images. The fine-tuning process has been optimized to accurately decode alphanumeric characters typically found on license plates.
Model Description
The base model, microsoft/trocr-base-handwritten
, is a Transformer-based OCR model designed for recognizing handwritten text. This fine-tuned version is adapted for license plate recognition, enhancing its ability to read and transcribe license plates from various sources, including images captured under different lighting and angles.
Intended Uses & Limitations
Intended Uses
- License Plate Recognition: This model is designed to extract and transcribe alphanumeric characters from images of license plates. It can be used in various applications such as automated toll systems, parking management, and law enforcement.
Limitations
- Character Set: The model is optimized for the specific alphanumeric characters commonly found on license plates. It may not perform well on text outside this domain.
- Environmental Factors: While robust to typical variations in image quality, extreme conditions like very low light, heavy blurring, or unusual angles may reduce accuracy.
Training and Evaluation Data
The model was fine-tuned on a dataset consisting of license plate images. The dataset includes a diverse set of license plates captured in various environments and lighting conditions, ensuring robustness in real-world applications. However, specific details about the dataset (e.g., size, source) are not provided here.
Training Procedure
Training Hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e-05
- train_batch_size: 8
- eval_batch_size: 8
- seed: 42
- optimizer: Adam with betas=(0.9, 0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 7
Training Results
Training Loss | Epoch | Step | Validation Loss | Cer |
---|---|---|---|---|
0.2605 | 1.0 | 254 | 0.0798 | 0.0253 |
0.138 | 2.0 | 508 | 0.0660 | 0.0177 |
0.0435 | 3.0 | 762 | 0.0645 | 0.0146 |
0.0344 | 4.0 | 1016 | 0.0594 | 0.0173 |
0.011 | 5.0 | 1270 | 0.0626 | 0.0160 |
0.0021 | 6.0 | 1524 | 0.0567 | 0.0120 |
0.0007 | 7.0 | 1778 | 0.0599 | 0.0137 |
Final Evaluation Metrics
- Loss: 0.0653
- Cer: 0.0231
Certainly! Here’s the updated "How to Use the Model" section with the correct username:
How to Use the Model
Here is how you can use this fine-tuned model in PyTorch to recognize license plate numbers:
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
from PIL import Image
import requests
# Load an image of a license plate
url = 'https://example.com/path/to/license_plate_image.jpg'
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
# Initialize the processor and the fine-tuned model
processor = TrOCRProcessor.from_pretrained('PawanKrGunjan/license_plate_recognizer')
model = VisionEncoderDecoderModel.from_pretrained('PawanKrGunjan/license_plate_recognizer')
# Preprocess the image
pixel_values = processor(images=image, return_tensors="pt").pixel_values
# Generate text (license plate number)
generated_ids = model.generate(pixel_values)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print("Recognized License Plate Number:", generated_text)
In this example:
- Replace the
url
with the actual URL of an image containing a license plate. - The model and processor are loaded from your fine-tuned model on the Hugging Face Hub (
PawanKrGunjan/license_plate_recognizer
).
Framework Versions
- Transformers: 4.42.3
- Pytorch: 2.1.2
- Datasets: 2.20.0
- Tokenizers: 0.19.1