Skip to main content

platedet

platedet is a lightweight package for detecting license plates in images using an ONNX model. It is designed to be part of a pipeline for detecting, cropping, and reading license plates. The underlying model is just YOLO, converted to ONNX format. The training data comprises primarily Brazilian license plates, sourced from internet images.

Installation

To install the required dependencies, use the following command:

For cpu

pip install "platedet[cpu]"

For cuda 11.X

pip install "platedet[gpu]"

For cuda 12.X

pip install "platedet[gpu]" --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/

Usage

Command Line Interface

You can use the command line interface to detect license plates in an image:

platedet image_path [--model_path MODEL_PATH] [--return_types RETURN_TYPES] [--providers PROVIDERS] [--save_images] [--show_result]

Arguments

  • image_path: Path to the input image.
  • --model_path: Path to the ONNX model (default: artifacts/platedet.onnx).
  • --return_types: Output formats (choices: raw, pil, np_array, boxes).
  • --providers: ONNX Runtime providers (default: CPUExecutionProvider).
  • --save_images: Save cropped images of detected plates.
  • --show_result: Display results with bounding boxes and confidence scores.

Example

To detect license plates and save the cropped images:

platedet path/to/image.png --save_images

To display the results with bounding boxes:

platedet detect.py path/to/image.png --show_result

Using in Code

from PIL import Image
from platedet import Platedet

platedet = Platedet()
image = Image.open('examples/1.jpg')
crops = platedet.inference(image, return_types=['pil'])
for idx, crop in enumerate(crops['pil']['images']):
    crop.save(f'{idx}.jpg')

If you want to use CUDA:

from PIL import Image
from platedet import Platedet

platedet = Platedet(providers=["CUDAExecutionProvider"])
image = Image.open('examples/1.jpg')
crops = platedet.inference(image, return_types=['pil'])
for idx, crop in enumerate(crops['pil']['images']):
    crop.save(f'{idx}.jpg')

Check all execution providers here.

Metadata

Release files for platedet 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for platedet 0.0.2
File Interpreter ABI Platform
platedet-0.0.2-py3-none-any.whl Python 3 none any Details

Release files / platedet-0.0.2-py3-none-any.whl

Download URL platedet-0.0.2-py3-none-any.whl
Size 21.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c39c602c4824809fa2e2f6c213f1fb1211b966bc99776c16c41d80caadf80d4f
BLAKE2b-256 checksum
How to use checksums
50370ecc8ab264aff7c5e6478edbd35fc4cbd15374f7272f22669aea8a188f2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page