Detect license plates
Project description
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.
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 Distributions
Built Distribution
File details
Details for the file platedet-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: platedet-0.0.2-py3-none-any.whl
- Upload date:
- Size: 21.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c39c602c4824809fa2e2f6c213f1fb1211b966bc99776c16c41d80caadf80d4f |
|
MD5 | 2d78951b386d45ba77b6ba827b943636 |
|
BLAKE2b-256 | 50370ecc8ab264aff7c5e6478edbd35fc4cbd15374f7272f22669aea8a188f2d |