>_ DevTrendsen

Language

Home

Languages

Sections

Frontend Backend Mobile DevOps AI / ML GameDev Blockchain Embedded Security
Python

License Plate Recognition at Three Thousand Frames per Second

When building an automatic control pipeline for a parking lot or highway, license plate recognition quickly hits a performance wall. Standard approaches with Tesseract or heavy EasyOCR consume dozens of milliseconds per cropped license plate rectangle. With multiple cameras and cars flowing through, the server starts choking or requires an expensive GPU farm.

Intro

Recently came across the repository fast-plate-ocr by developer ankandrew. The project solves exactly one narrow task, but does it fast. It takes a license plate already cropped by a detector and reads characters in fractions of a millisecond.

Why a Separate Library for License Plate OCR

In computer vision for ALPR (Automatic License Plate Recognition), the pipeline is usually divided into two steps:

  1. The detector finds the car and crops the license plate (for example, via YOLO).
  2. The text recognition model reads the actual plate number.

Universal text OCRs are trained on books, receipts, signs, and documents. Because of this, the architectures end up being bulky, and they regularly make mistakes on plates with non-standard fonts or complex angles.

The fast-plate-ocr library uses compact models based on the CCT (Compact Convolutional Transformer) architecture. These networks are specifically designed for recognizing small structured images without redundant parameters. Thanks to the lightweight architecture and execution via ONNX Runtime, latency on a single image on the RTX 3090 ranges from 0.32 to 0.67 ms. Translated to throughput, this is 14,000 to 3,000 plates per second on a single card.

What's Under the Hood and How It Works

The repository includes a ready-made model zoo, training scripts, and export tools.

Ready-Made CCT Models

The author has prepared several model versions:

  • cct-xs-v1-global-model and cct-xs-v2-global-model — the smallest networks with 0.3-0.4 ms latency.
  • cct-s-v1-global-model and cct-s-v2-global-model — slightly deeper variants where priority is given to accuracy on complex viewing angles.

The second versions (v2) add a separate head for classifying the region or country of the license plate. If the camera captures international traffic, the model immediately returns both the text and the country of origin of the plate.

Flexible Runtime Selection

A common pain point when deploying neural networks is being tied to heavy frameworks. Here, inference is separated from training. The library itself installs without heavy dependencies, and the ONNX Runtime backend is selected for the target hardware via pip extras:

# Для обычного процессора
pip install fast-plate-ocr[onnx]

# Для видеокарт NVIDIA
pip install fast-plate-ocr[onnx-gpu]

# Оптимизация под процессоры Intel
pip install fast-plate-ocr[onnx-openvino]

# Поддержка DirectML для Windows
pip install fast-plate-ocr[onnx-directml]

# Чипсеты Qualcomm
pip install fast-plate-ocr[onnx-qnn]

This is convenient if the project needs to be built into a lightweight Docker container or run on a microcomputer at a gate.

Quick Start in Code

Working with the library comes down to a couple of lines. First, initialize the recognizer by passing the name of the desired model from the hub, then provide the path to an image or a NumPy array.

from fast_plate_ocr import LicensePlateRecognizer

# Загружаем готовую предобученную модель
recognizer = LicensePlateRecognizer('cct-s-v2-global-model')

# Распознаем текст на вырезанной плашке
result = recognizer.run('test_plate.png')
print(result)

If the model supports region detection, you can request a confidence score:

from fast_plate_ocr import LicensePlateRecognizer

recognizer = LicensePlateRecognizer('cct-s-v2-global-model')
prediction = recognizer.run('test_plate.png', return_confidence=True)[0]

print(f"Номер: {prediction.text}")
print(f"Регион: {prediction.region}")
print(f"Уверенность в регионе: {prediction.region_prob:.2f}")

There's also a built-in method for benchmarking performance on your machine:

recognizer.benchmark()

Training and Fine-Tuning for Your Own Plates

Although global models handle standard formats reasonably well, real-world projects often encounter specific license plates: military, diplomatic, two-line, or regional formats from a particular country.

Training uses Keras 3, so you can train the network with any familiar backend — PyTorch, TensorFlow, or JAX. To install dependencies for training, just run:

pip install fast-plate-ocr[train]

The repository contains a ready-made Jupyter Notebook (examples/tutorial_fine_tune_plate_model.ipynb) that walks through the process step by step:

  1. Preparing a dataset of labeled crops and a dictionary of allowed characters.
  2. Configuring augmentations via a YAML file.
  3. Fine-tuning the model on your own data.
  4. Exporting weights to ONNX, TFLite, or CoreML.

The ability to export a trained network to TFLite or CoreML removes the headache if you need to embed recognition directly into a mobile app for inspectors or parking attendants.

What to Keep in Mind

The project is focused only on the OCR step. It doesn't search for a car in the frame and doesn't correct the perspective of the plate if it was shot at a sharp angle.

If you feed an entire frame with the whole street, the model will output garbage. A detector (YOLOv8, RT-DETR, or any other) must always precede fast-plate-ocr to find the coordinates of the plate and crop the image. For best results with a heavily tilted camera, add perspective transform before feeding into OCR.

Who This Project Is For

The library will appeal to those building real video analytics systems and fighting for millisecond latency:

  • Parking management systems and automatic barriers based on mini-PCs.
  • Weight and dimension control complexes and traffic monitoring.
  • Mobile apps for paid parking enforcement.

The project is open-source, the code is clear, and dependencies are minimal. If you're tired of fighting the slowness of universal OCR libraries on transport tasks, fast-plate-ocr will save both server resources and development time.

Related projects