Fast Automatic License Plate Recognition.
Project description
FastALPR
FastALPR is a high-performance, customizable Automatic License Plate Recognition (ALPR) system. We offer fast and efficient ONNX models by default, but you can easily swap in your own models if needed.
For Optical Character Recognition (OCR), we use fast-plate-ocr by default, and for license plate detection, we use open-image-models. However, you can integrate any OCR or detection model of your choice.
📋 Table of Contents
- ✨ Features
- 📦 Installation
- 🚀 Quick Start
- 🛠️ Customization and Flexibility
- 📖 Documentation
- 🤝 Contributing
- 🙏 Acknowledgements
- 📫 Contact
✨ Features
- High Accuracy: Uses advanced models for precise license plate detection and OCR.
- Customizable: Easily switch out detection and OCR models.
- Easy to Use: Quick setup with a simple API.
- Out-of-the-Box Models: Includes ready-to-use detection and OCR models
- Fast Performance: Optimized with ONNX Runtime for speed.
📦 Installation
pip install fast-alpr
🚀 Quick Start
Here's how to get started with FastALPR:
from fast_alpr import ALPR
# You can also initialize the ALPR with custom plate detection and OCR models.
alpr = ALPR(
detector_model="yolo-v9-t-384-license-plate-end2end",
ocr_model="european-plates-mobile-vit-v2-model",
)
# The "assets/test_image.png" can be found in repo root dit
alpr_results = alpr.predict("assets/test_image.png")
print(alpr_results)
Output:
You can also draw the predictions directly on the image:
import cv2
from fast_alpr import ALPR
# Initialize the ALPR
alpr = ALPR(
detector_model="yolo-v9-t-384-license-plate-end2end",
ocr_model="european-plates-mobile-vit-v2-model",
)
# Load the image
image_path = "assets/test_image.png"
frame = cv2.imread(image_path)
# Draw predictions on the image
annotated_frame = alpr.draw_predictions(frame)
# Display the result
cv2.imshow("ALPR Result", annotated_frame)
cv2.waitKey(0)
cv2.destroyAllWindows()
Output:
🛠️ Customization and Flexibility
FastALPR is designed to be flexible. You can customize the detector and OCR models according to your requirements. You can very easily integrate with Tesseract OCR to leverage its capabilities:
import re
from statistics import mean
import numpy as np
import pytesseract
from fast_alpr.alpr import ALPR, BaseOCR, OcrResult
class PytesseractOCR(BaseOCR):
def __init__(self) -> None:
"""
Init PytesseractOCR.
"""
def predict(self, cropped_plate: np.ndarray) -> OcrResult | None:
if cropped_plate is None:
return None
# You can change 'eng' to the appropriate language code as needed
data = pytesseract.image_to_data(
cropped_plate,
lang="eng",
config="--oem 3 --psm 6",
output_type=pytesseract.Output.DICT,
)
plate_text = " ".join(data["text"]).strip()
plate_text = re.sub(r"[^A-Za-z0-9]", "", plate_text)
avg_confidence = mean(conf for conf in data["conf"] if conf > 0) / 100.0
return OcrResult(text=plate_text, confidence=avg_confidence)
alpr = ALPR(detector_model="yolo-v9-t-384-license-plate-end2end", ocr=PytesseractOCR())
alpr_results = alpr.predict("assets/test_image.png")
print(alpr_results)
[!TIP] See the docs for more examples!
📖 Documentation
Comprehensive documentation is available here, including detailed API references and additional examples.
🤝 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-alpr.git
- Install all dependencies using Poetry:
poetry install --all-extras
- To ensure your changes pass linting and tests before submitting a PR:
make checks
🙏 Acknowledgements
- fast-plate-ocr for default OCR models.
- open-image-models for default plate detection models.
📫 Contact
For questions or suggestions, feel free to open an issue or reach out through social networks.
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
File details
Details for the file fast_alpr-0.1.1.tar.gz
.
File metadata
- Download URL: fast_alpr-0.1.1.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | febf1ee6500e1b5043288e18a7dc87ca0a0b50435387cc397c5d84ec631392fc |
|
MD5 | 0eb67ec694f4bae231c2a3599824e6a5 |
|
BLAKE2b-256 | d5c2152228f97f640ad3dd4617de8bae3af93eab888ab2104c3d8fefa9a1654c |
Provenance
The following attestation bundles were made for fast_alpr-0.1.1.tar.gz
:
Publisher:
main.yaml
on ankandrew/fast-alpr
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
fast_alpr-0.1.1.tar.gz
- Subject digest:
febf1ee6500e1b5043288e18a7dc87ca0a0b50435387cc397c5d84ec631392fc
- Sigstore transparency entry: 148280129
- Sigstore integration time:
- Predicate type:
File details
Details for the file fast_alpr-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: fast_alpr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 462fd84c6a3e803e31f6c6a25ab8d1106dc76e53ed7934c6ce60c2e7bce64671 |
|
MD5 | f36721b2c55ab4b7f221b2b097a6ceab |
|
BLAKE2b-256 | f792bf34980b3021aa6fea19a95fe173fc26c8d76cfed852a5a88a60959e5d29 |
Provenance
The following attestation bundles were made for fast_alpr-0.1.1-py3-none-any.whl
:
Publisher:
main.yaml
on ankandrew/fast-alpr
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
fast_alpr-0.1.1-py3-none-any.whl
- Subject digest:
462fd84c6a3e803e31f6c6a25ab8d1106dc76e53ed7934c6ce60c2e7bce64671
- Sigstore transparency entry: 148280132
- Sigstore integration time:
- Predicate type: