diff --git a/Makefile b/Makefile index 4790618..10fcb7d 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,5 @@ # Directories -SRC_PATHS := fast_plate_ocr/ \ - test/ \ - train.py \ - valid.py \ - visualize_augmentation.py \ - visualize_predictions.py \ - onnx_converter.py +SRC_PATHS := fast_plate_ocr/ test/ # Tasks .PHONY: help diff --git a/fast_plate_ocr/cli/cli.py b/fast_plate_ocr/cli/cli.py new file mode 100644 index 0000000..8a8fce2 --- /dev/null +++ b/fast_plate_ocr/cli/cli.py @@ -0,0 +1,26 @@ +""" +Main CLI used when training a FastPlateOCR model. +""" + +try: + import click + + from fast_plate_ocr.cli.onnx_converter import export_onnx + from fast_plate_ocr.cli.train import train + from fast_plate_ocr.cli.valid import valid + from fast_plate_ocr.cli.visualize_augmentation import visualize_augmentation + from fast_plate_ocr.cli.visualize_predictions import visualize_predictions +except ImportError as e: + raise ImportError("Make sure to 'pip install fast-plate-ocr[train]' to run this!") from e + + +@click.group(context_settings={"max_content_width": 120}) +def main_cli(): + """FastPlateOCR CLI.""" + + +main_cli.add_command(visualize_predictions) +main_cli.add_command(visualize_augmentation) +main_cli.add_command(valid) +main_cli.add_command(train) +main_cli.add_command(export_onnx) diff --git a/onnx_converter.py b/fast_plate_ocr/cli/onnx_converter.py similarity index 100% rename from onnx_converter.py rename to fast_plate_ocr/cli/onnx_converter.py diff --git a/train.py b/fast_plate_ocr/cli/train.py similarity index 100% rename from train.py rename to fast_plate_ocr/cli/train.py diff --git a/valid.py b/fast_plate_ocr/cli/valid.py similarity index 100% rename from valid.py rename to fast_plate_ocr/cli/valid.py diff --git a/visualize_augmentation.py b/fast_plate_ocr/cli/visualize_augmentation.py similarity index 100% rename from visualize_augmentation.py rename to fast_plate_ocr/cli/visualize_augmentation.py diff --git a/visualize_predictions.py b/fast_plate_ocr/cli/visualize_predictions.py similarity index 100% rename from visualize_predictions.py rename to fast_plate_ocr/cli/visualize_predictions.py diff --git a/poetry.lock b/poetry.lock index 830f9a2..2d22c70 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2863,4 +2863,4 @@ train = ["albumentations", "click", "keras", "matplotlib", "pandas", "pydantic", [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "4ea60388842240b61706492fb85553baf51718a12eebbe2cf647cc059b130490" +content-hash = "a0cf7f7dbb319c63116ff4ab165bb79884db9191503642922fbe591c40c65155" diff --git a/pyproject.toml b/pyproject.toml index 3c61836..60e3bfe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,9 @@ pandas-stubs = "^2.2.0.240218" pylint = "^3.1.0" types-pyyaml = "^6.0.12.20240311" +[tool.poetry.scripts] +plate_ocr = "fast_plate_ocr.cli.cli:main_cli" + [tool.ruff] line-length = 100 target-version = "py310"