fast-plate-ocr

ankandrewMIT更新放缓

轻量级车牌文字识别 OCR 模型,支持 Keras、JAX 和 ONNX Runtime,可快速集成到车牌识别流水线中。

Lightweight & fast OCR models for license plate text recognition.

v1.1.0发布于 2026-03-14 20:22 UTC806star104fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
pip install fast-plate-ocr[onnx-gpu]
硬件要求按 README 说明

README 未给出显存要求;基准测试在 NVIDIA RTX 3090 上完成,推理可走 CPU、NVIDIA CUDA、Intel OpenVINO、Windows DirectML、Qualcomm QNN 等多种执行后端。

需要 CUDA
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

轻量快速的车牌文字识别 OCR 模型,接在车牌检测器之后对裁剪车牌图做识别

轻量级车牌文字识别 OCR 模型,支持 Keras、JAX 和 ONNX Runtime,可快速集成到车牌识别流水线中。

核心能力

  • 基于 CCT 架构提供 XS/S 多档预训练模型
  • 用 ONNX Runtime 做优化推理,支持 GPU 加速
  • Keras 3 后端可选 TensorFlow、JAX 或 PyTorch 训练
  • 支持微调自有数据集并导出 CoreML、TFLite、ONNX
  • 可选区域识别头预测车牌所属国家或地区

容易踩的坑

默认不安装任何 ONNX Runtime,必须按平台选装 onnx、onnx-gpu 等 extra 才能推理;训练需另装 fast-plate-ocr[train];OCR 只接受已裁剪的车牌图,需先接车牌检测器。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.1.0
  1. v1.1.0fast-plate-ocr 1.1.0最新正式版2026-03-14 · 2026-03-14 20:22 UTC

    Highlights

    Added

    • New cct-xs-v2-global-model and cct-s-v2-global-model with plate region recognition support for 65+ countries.
    • Optional region-aware training, validation, and inference flow, including plate_region dataset support.
    • New region evaluation metrics, including val_region_macro_f1, plus per-region evaluation in validation.
    • New CCT v2 model configs, parameterized plate configs, and focal loss support for region classification.
    • Inference now returns PlatePrediction, exposing region outputs when available.
    • Export pipeline improvements for multi-output models, plus support for selecting the ONNX opset version.
    • Expanded dataset validation and annotation checks, including region validation and warnings on unexpected columns.

    Changed

    • V2 pre-trained models were trained on roughly 3x more data than the v1 generation.
    • V2 training now includes empty plates built from backgrounds, noise, textures, and other padded-plate negatives.
    • Region recognition now includes an Unknown class trained mainly with synthetic data.
    • Updated the new CCT v2 models to use silu instead of gelu to avoid export issues with some library versions.
    • Added the corrected attention_layout behavior so split projection dimensions are distributed per head instead of reusing the full projection_dim.
    • The shipped v2 xs and s pre-trained models both exceed 0.99 val_region_macro_f1 on a held-out validation split with more than 114_000 samples.
    • Transformer blocks and training defaults are more configurable, including projection validation, loss weighting, and milder augmentations.
    • Inference now removes the pad character by default from decoded output.
    • TFLite export now uses LiteRT via ai-edge-litert following TensorFlow deprecation changes.

    Fixed

    • Fixed region recognition mismatches during validation.
    • Fixed EarlyStopping metric selection when training single-head models.
    • Fixed learning-rate decay step calculation to account for warmup steps.

    Full Changelog: https://github.com/ankandrew/fast-plate-ocr/compare/v1.0.2...v1.1.0

  2. v1.0.2fast-plate-ocr 1.0.22025-09-06 · 2025-09-06 02:59 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/ankandrew/fast-plate-ocr/compare/v1.0.1...v1.0.2

  3. v1.0.1fast-plate-ocr 1.0.12025-07-06 · 2025-07-06 01:22 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/ankandrew/fast-plate-ocr/compare/v1.0.0...v1.0.1

  4. v1.0.0fast-plate-ocr 1.0.02025-06-30 · 2025-06-30 02:53 UTC
    查看更新说明

    What's Changed

    Added

    • New XS and S CCT model variants, trained with x3 more data (220k global plates).
    • Complete rework of docs, documenting much more everything.
    • Inference now works smoothly with different onnxruntime variants like onnxruntime-gpu, onnxruntime-openvino, etc.
    • Support for building and customizing CCT (Compact Convolutional Transformer) models from YAML configs.
    • New model building logic, allows users to build custom-based architectures while validating it with Pydantic.
    • New metric val_plate_len_acc.
    • Added support for categorical focal loss.
    • Added more test coverage (configs, train scripts, etc.).
    • New validate_dataset.py script to help check datasets before training.
    • Export script now officially supports more formats like TFLite and CoreML.
    • New plate config support: keep_aspect_ratio, interpolation, image_color_mode and padding_color.
    • New default augmentation for RGB image mode.
    • New default models, trained with much more data.
    • Added examples and more docs.

    Changed

    • Visualize augmentation script now respects config-based preprocessing.
    • Improved plate config validation.
    • ONNXPlateRecognizer is now called LicensePlateRecognizer.

    Full Changelog: https://github.com/ankandrew/fast-plate-ocr/compare/v0.3.0...v1.0.0

  5. v0.3.0fast-plate-ocr 0.3.02024-12-08 · 2024-12-08 16:42 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/ankandrew/fast-plate-ocr/compare/v0.2.0...v0.3.0

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Fast & Lightweight License Plate OCR

    Actions status Actions status Keras 3 image image Ruff Pylint Checked with mypy ONNX Model Hugging Face Spaces Documentation Status image

    Intro


    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 🧠
    • 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 🛠️
    • Region Recognition (Optional): Predict region/country of the license plate 🌍
    • 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 NameSizeArchb=1 Avg. Latency (ms)Plates/sec (PPS)Model ConfigPlate ConfigVal Results
    cct-s-v2-global-modelSCCT0.67581479.61model_config.yamlplate_config.yamlresults
    cct-xs-v2-global-modelXSCCT0.46642144.14model_config.yamlplate_config.yamlresults
    cct-s-v1-global-modelSCCT0.58771701.63model_config.yamlplate_config.yamlresults
    cct-xs-v1-global-modelXSCCT0.32323094.21model_config.yamlplate_config.yamlresults

    [!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 CaseInstall CommandNotes
    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-s-v2-global-model')
    print(m.run('test_plate.png'))
    

    If your model includes a region head (and plate_regions is defined in the plate config), predictions also include region. The region_prob field is populated when return_confidence=True:

    from fast_plate_ocr import LicensePlateRecognizer
    
    m = LicensePlateRecognizer('cct-s-v2-global-model')
    pred = m.run('test_plate.png', return_confidence=True)[0]
    print(pred.region, pred.region_prob)
    

    To run a model benchmark:

    from fast_plate_ocr import LicensePlateRecognizer
    
    m = LicensePlateRecognizer('cct-s-v2-global-model')
    m.benchmark()
    

    For more examples and the full API, see the Inference Guide and Reference.

    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.

    For region recognition and export-friendly activations, use the v2 models.

    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:

    1. Clone repo
      git clone https://github.com/ankandrew/fast-plate-ocr.git
      
    2. Install all dependencies (make sure you have uv installed):
      make install
      
    3. 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}
    }