🛠Pipelines Overview¶
License Plate Detection¶
🚗 License Plate Detection allows you to detect and identify license plates in images using a specialized pipeline based on the YOLOv9 model.
The LicensePlateDetector
is specialized for license plate detection. It utilizes the YOLOv9 object detection model to recognize license plates in images.
Bases: YoloV9ObjectDetector
Specialized detector for license plates using YoloV9 model. Inherits from YoloV9ObjectDetector and sets up license plate specific configuration.
Source code in open_image_models/detection/pipeline/license_plate.py
__init__(detection_model, conf_thresh=0.25, providers=None, sess_options=None)
¶
Initializes the LicensePlateDetector with the specified detection model and inference device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
detection_model |
PlateDetectorModel
|
Detection model to use, see |
required |
conf_thresh |
float
|
Confidence threshold for filtering predictions. |
0.25
|
providers |
Sequence[str | tuple[str, dict]] | None
|
Optional sequence of providers in order of decreasing precedence. If not specified, all available providers are used. |
None
|
sess_options |
SessionOptions
|
Advanced session options for ONNX Runtime. |
None
|
Source code in open_image_models/detection/pipeline/license_plate.py
predict(images)
¶
Perform license plate detection on one or multiple images.
This method is a specialized version of the YoloV9ObjectDetector.predict
method,
focusing on detecting license plates in images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images |
Any
|
A single image as a numpy array, a single image path as a string, a list of images as numpy arrays, or a list of image file paths. |
required |
Returns:
Type | Description |
---|---|
list[DetectionResult] | list[list[DetectionResult]]
|
A list of |
Example usage:
from open_image_models import LicensePlateDetector
lp_detector = LicensePlateDetector(detection_model="yolo-v9-t-384-license-plate-end2end")
lp_detector.predict("path/to/license_plate_image.jpg")
Raises:
Type | Description |
---|---|
ValueError
|
If the image could not be loaded or processed. |
Source code in open_image_models/detection/pipeline/license_plate.py
Core API Documentation¶
The core
module provides base classes and protocols for object detection models, including essential data structures like BoundingBox
and DetectionResult
.
🔧 Core Components¶
The following components are used across detection pipelines and models:
BoundingBox
: Represents a bounding box for detected objects.DetectionResult
: Stores label, confidence, and bounding box for a detection.ObjectDetector
: Protocol defining essential methods likepredict
,show_benchmark
, anddisplay_predictions
.
BoundingBox
dataclass
¶
Represents a bounding box with top-left and bottom-right coordinates.
Source code in open_image_models/detection/core/base.py
DetectionResult
dataclass
¶
Represents the result of an object detection.
Source code in open_image_models/detection/core/base.py
ObjectDetector
¶
Bases: Protocol
Source code in open_image_models/detection/core/base.py
display_predictions(image)
¶
Run object detection on the input image and display the predictions on the image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
ndarray
|
An input image as a numpy array. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The image with bounding boxes and labels drawn on it. |
Source code in open_image_models/detection/core/base.py
predict(images)
¶
Perform object detection on one or multiple images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
images |
Any
|
A single image as a numpy array, a single image path as a string, a list of images as numpy arrays, or a list of image file paths. |
required |
Returns:
Type | Description |
---|---|
list[DetectionResult] | list[list[DetectionResult]]
|
A list of DetectionResult for a single image input, |
list[DetectionResult] | list[list[DetectionResult]]
|
or a list of lists of DetectionResult for multiple images. |
Source code in open_image_models/detection/core/base.py
show_benchmark(num_runs=10)
¶
Display the benchmark results of the model with a single random image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_runs |
int
|
Number of times to run inference on the image for averaging. |
10
|
Displays
Model information and benchmark results in a formatted table.
Source code in open_image_models/detection/core/base.py
Open Image Models HUB.
PlateDetectorModel = Literal['yolo-v9-t-640-license-plate-end2end', 'yolo-v9-t-512-license-plate-end2end', 'yolo-v9-t-384-license-plate-end2end', 'yolo-v9-t-256-license-plate-end2end']
module-attribute
¶
Available ONNX models for doing detection.