HUB
Utilities function used for doing inference with the OCR models.
OcrModel
module-attribute
¶
OcrModel = Literal[
"cct-s-v1-global-model",
"cct-xs-v1-global-model",
"argentinian-plates-cnn-model",
"argentinian-plates-cnn-synth-model",
"european-plates-mobile-vit-v2-model",
"global-plates-mobile-vit-v2-model",
]
Available OCR models for doing inference.
AVAILABLE_ONNX_MODELS
module-attribute
¶
AVAILABLE_ONNX_MODELS: dict[OcrModel, tuple[str, str]] = {
"cct-s-v1-global-model": (
f"{BASE_URL}/arg-plates/cct_s_v1_global.onnx",
f"{BASE_URL}/arg-plates/cct_s_v1_global_plate_config.yaml",
),
"cct-xs-v1-global-model": (
f"{BASE_URL}/arg-plates/cct_xs_v1_global.onnx",
f"{BASE_URL}/arg-plates/cct_xs_v1_global_plate_config.yaml",
),
"argentinian-plates-cnn-model": (
f"{BASE_URL}/arg-plates/arg_cnn_ocr.onnx",
f"{BASE_URL}/arg-plates/arg_cnn_ocr_config.yaml",
),
"argentinian-plates-cnn-synth-model": (
f"{BASE_URL}/arg-plates/arg_cnn_ocr_synth.onnx",
f"{BASE_URL}/arg-plates/arg_cnn_ocr_config.yaml",
),
"european-plates-mobile-vit-v2-model": (
f"{BASE_URL}/arg-plates/european_mobile_vit_v2_ocr.onnx",
f"{BASE_URL}/arg-plates/european_mobile_vit_v2_ocr_config.yaml",
),
"global-plates-mobile-vit-v2-model": (
f"{BASE_URL}/arg-plates/global_mobile_vit_v2_ocr.onnx",
f"{BASE_URL}/arg-plates/global_mobile_vit_v2_ocr_config.yaml",
),
}
Dictionary of available OCR models and their URLs.
MODEL_CACHE_DIR
module-attribute
¶
Default location where models will be stored.
download_model ¶
download_model(
model_name: OcrModel,
save_directory: Path | None = None,
force_download: bool = False,
) -> tuple[Path, Path]
Download an OCR model and the config to a given directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
OcrModel
|
Which model to download. |
required |
save_directory
|
Path | None
|
Directory to save the OCR model. It should point to a folder.
If not supplied, this will point to '~/.cache/ |
None
|
force_download
|
bool
|
Force and download the model if it already exists in
|
False
|
Returns:
Type | Description |
---|---|
tuple[Path, Path]
|
A tuple consisting of (model_downloaded_path, config_downloaded_path). |