Fast & Lightweight OCR for vehicle license plates.
Project description
Fast & Lightweight License Plate OCR
Introduction
Lightweight and fast OCR models for license plate text recognition. You can train models from scratch or use the trained models for inference.
The idea is to use this after a plate object detector, since the OCR expects the cropped plates.
Features
- Keras 3 Backend Support: Train seamlessly using TensorFlow, JAX, or PyTorch backends 🧠
- Augmentation Variety: Diverse training-time augmentations via Albumentations library 🖼️
- Efficient Execution: Lightweight models that are cheap to run 💰
- ONNX Runtime Inference: Fast and optimized inference with ONNX runtime ⚡
- User-Friendly CLI: Simplified CLI for training and validating OCR models 🛠️
- Model HUB: Access to a collection of pre-trained models ready for inference 🌟
- Train/Fine-tune: Easily train or fine-tune your own models 🔧
- Export-Friendly: Export easily to CoreML, TFLite, or ONNX formats 📦
Available Models
Optimized, ready to use models with config files for inference or fine-tuning.
| Model Name | Size | Arch | b=1 Avg. Latency (ms) | Plates/sec (PPS) | Model Config | Plate Config | Val Results |
|---|---|---|---|---|---|---|---|
cct-s-v1-global-model |
S | CCT | 0.5877 | 1701.63 | model_config.yaml | plate_config.yaml | results |
cct-xs-v1-global-model |
XS | CCT | 0.3232 | 3094.21 | model_config.yaml | plate_config.yaml | results |
[!TIP] 🚀 Try the above models in Hugging Spaces.
[!NOTE] Benchmark Setup
These results were obtained with:
- Hardware: NVIDIA RTX 3090 GPU
- Execution Providers:
['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider']- Install dependencies:
pip install fast-plate-ocr[onnx-gpu]
Explore the Model Zoo to see all available models.
Inference
For doing inference, install:
pip install fast-plate-ocr[onnx-gpu]
By default, no ONNX runtime is installed. To run inference, you must install at least one ONNX backend using an appropriate extra.
| Platform/Use Case | Install Command | Notes |
|---|---|---|
| CPU (default) | pip install fast-plate-ocr[onnx] |
Cross-platform |
| NVIDIA GPU (CUDA) | pip install fast-plate-ocr[onnx-gpu] |
Linux/Windows |
| Intel (OpenVINO) | pip install fast-plate-ocr[onnx-openvino] |
Best on Intel CPUs |
| Windows (DirectML) | pip install fast-plate-ocr[onnx-directml] |
For DirectML support |
| Qualcomm (QNN) | pip install fast-plate-ocr[onnx-qnn] |
Qualcomm chipsets |
Usage
To predict from disk image:
from fast_plate_ocr import LicensePlateRecognizer
m = LicensePlateRecognizer('cct-xs-v1-global-model')
print(m.run('test_plate.png'))
Run demo
To run model benchmark:
from fast_plate_ocr import LicensePlateRecognizer
m = LicensePlateRecognizer('cct-xs-v1-global-model')
m.benchmark()
Benchmark demo
Training
You can train models from scratch or fine-tune a pre-trained one using your own license plate dataset.
Install the training dependencies:
pip install fast-plate-ocr[train]
Fine-tuning Tutorial
A complete tutorial notebook is available for fine-tuning a license plate OCR model on your own dataset:
examples/fine_tune_workflow.ipynb. It covers the full workflow, from
preparing your dataset to training and exporting the model.
For full details on data preparation, model configs, fine-tuning, and training commands, check out the docs.
Contributing
Contributions to the repo are greatly appreciated. Whether it's bug fixes, feature enhancements, or new models, your contributions are warmly welcomed.
To start contributing or to begin development, you can follow these steps:
- Clone repo
git clone https://github.com/ankandrew/fast-plate-ocr.git
- Install all dependencies (make sure you have uv installed):
make install - To ensure your changes pass linting and tests before submitting a PR:
make checks
Citations
@article{hassani2021escaping,
title = {Escaping the Big Data Paradigm with Compact Transformers},
author = {Ali Hassani and Steven Walton and Nikhil Shah and Abulikemu Abuduweili and Jiachen Li and Humphrey Shi},
year = 2021,
url = {https://arxiv.org/abs/2104.05704},
eprint = {2104.05704},
archiveprefix = {arXiv},
primaryclass = {cs.CV}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fast_plate_ocr-1.0.2.tar.gz.
File metadata
- Download URL: fast_plate_ocr-1.0.2.tar.gz
- Upload date:
- Size: 202.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7828bb991b0995d64506d7accee3dc4853044ac336c9e75c44d5145cfe25fa5d
|
|
| MD5 |
454ee1698dfa2ff0709f96bed0632a04
|
|
| BLAKE2b-256 |
5d4b0fa275bf59320da58ce17eb9f93fd57f8ad92288ebe69d7ce4c1374a9833
|
Provenance
The following attestation bundles were made for fast_plate_ocr-1.0.2.tar.gz:
Publisher:
release.yaml on ankandrew/fast-plate-ocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fast_plate_ocr-1.0.2.tar.gz -
Subject digest:
7828bb991b0995d64506d7accee3dc4853044ac336c9e75c44d5145cfe25fa5d - Sigstore transparency entry: 477344604
- Sigstore integration time:
-
Permalink:
ankandrew/fast-plate-ocr@cb20d1e1e866d67324938f6215c06338adb8d779 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/ankandrew
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@cb20d1e1e866d67324938f6215c06338adb8d779 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fast_plate_ocr-1.0.2-py3-none-any.whl.
File metadata
- Download URL: fast_plate_ocr-1.0.2-py3-none-any.whl
- Upload date:
- Size: 54.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1899e304dd38a53a0071f60c0a982342834473dbd5b0df89d94f51edd26e99a0
|
|
| MD5 |
c48b9d823fc256685b4b2f9adeee8ef3
|
|
| BLAKE2b-256 |
acf1595f543343c0029d23c20364220e61f2eca2c551ea3a1c592deade0c256b
|
Provenance
The following attestation bundles were made for fast_plate_ocr-1.0.2-py3-none-any.whl:
Publisher:
release.yaml on ankandrew/fast-plate-ocr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fast_plate_ocr-1.0.2-py3-none-any.whl -
Subject digest:
1899e304dd38a53a0071f60c0a982342834473dbd5b0df89d94f51edd26e99a0 - Sigstore transparency entry: 477344637
- Sigstore integration time:
-
Permalink:
ankandrew/fast-plate-ocr@cb20d1e1e866d67324938f6215c06338adb8d779 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/ankandrew
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@cb20d1e1e866d67324938f6215c06338adb8d779 -
Trigger Event:
push
-
Statement type: