File size: 5,253 Bytes
88ed72f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2415b80
 
 
c04c2df
b0081fc
 
2415b80
 
b0081fc
2415b80
b0081fc
2415b80
b0081fc
2415b80
b0081fc
2415b80
b0081fc
 
2415b80
b0081fc
 
 
2415b80
b0081fc
2415b80
b0081fc
2415b80
b0081fc
 
 
2415b80
 
b0081fc
 
 
 
 
 
 
2415b80
b0081fc
2415b80
 
 
c04c2df
 
 
 
 
 
 
2415b80
b0081fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2415b80
b0081fc
2415b80
b0081fc
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
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
---
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->

[<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="200" height="32"/>](https://wandb.ai/pawankrgunjan/huggingface/runs/v5cu1qdh)


# license_plate_recognizer

This model is a fine-tuned version of [microsoft/trocr-base-handwritten](https://huggingface.co/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:

```python
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:
1. Replace the `url` with the actual URL of an image containing a license plate.
2. 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