5cedcaefe1
Add a dev CLI (uv run python -m vision_service.cli <image>) that runs a recognizer on an image file and prints the parsed plate(s) + confidence + region — fast feedback with no HTTP. Also a package.json `recognize` script and a vision-recognize entry point. Verified fast-alpr for real: installed the `alpr` extra, downloaded the YOLOv9 + CCT ONNX weights (~11MB, cached offline under ~/.cache), and ran recognition on the project's test image → "5AU5341" at 1.000 confidence, region "Czech Republic", ~40ms on CPU, via both the CLI and POST /analyze. Fixes result parsing against the actual fast-alpr API: ocr.confidence is a LIST of per-character confidences (not a scalar) — reduced to one plate confidence via the MIN (a plate is only as trustworthy as its weakest character); also surface ocr.region. Extracted the per-result mapping into a pure plate_from_alpr_result + _reduce_confidence and unit-tested them (no model weights needed). 7 tests pass; ruff + mypy strict clean; full turbo build/lint/test green. Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
63 lines
1.9 KiB
TOML
63 lines
1.9 KiB
TOML
[project]
|
|
name = "parking-vision"
|
|
version = "0.0.0"
|
|
description = "Host-side ANPR / vehicle-verification microservice for the parking system (separate process; localhost HTTP)."
|
|
requires-python = ">=3.10,<4.0"
|
|
# Core deps are LIGHT on purpose: the service boots, serves /health, and answers
|
|
# /analyze in stub mode with ONLY these. The heavy recognizer stack (fast-alpr +
|
|
# onnxruntime + model weights) is the optional `alpr` extra, so `uv sync` and the test
|
|
# suite work offline without downloading models. See
|
|
# wiki/decisions/vision-service-packaging.md + wiki/entities/opencv-anpr-service.md.
|
|
dependencies = [
|
|
"fastapi>=0.115",
|
|
"uvicorn[standard]>=0.32",
|
|
"pydantic>=2.9",
|
|
"pydantic-settings>=2.6",
|
|
]
|
|
|
|
[project.scripts]
|
|
vision-recognize = "vision_service.cli:main"
|
|
|
|
[project.optional-dependencies]
|
|
# The real recognizer. Install with: uv sync --extra alpr
|
|
# fast-alpr is MIT (YOLOv9 detector + CCT OCR, both MIT) on ONNX Runtime — see the
|
|
# recognizer evaluation in wiki/entities/opencv-anpr-service.md. onnxruntime is the
|
|
# CPU backend; swap for onnxruntime-gpu / -openvino / -directml on capable hardware.
|
|
alpr = [
|
|
"fast-alpr>=0.4.0",
|
|
"onnxruntime>=1.19",
|
|
]
|
|
|
|
[dependency-groups]
|
|
# Dev tooling (uv installs these by default for local work; excluded from the runtime image).
|
|
dev = [
|
|
"ruff>=0.8",
|
|
"pytest>=8.3",
|
|
"httpx>=0.27", # FastAPI TestClient transport
|
|
"mypy>=1.13",
|
|
]
|
|
|
|
[tool.ruff]
|
|
line-length = 110
|
|
target-version = "py310"
|
|
|
|
[tool.ruff.lint]
|
|
# A pragmatic default set: pyflakes, pycodestyle, isort, bugbear, pyupgrade.
|
|
select = ["E", "F", "I", "B", "UP"]
|
|
|
|
[tool.pytest.ini_options]
|
|
testpaths = ["tests"]
|
|
|
|
[tool.mypy]
|
|
python_version = "3.10"
|
|
strict = true
|
|
# fast-alpr / onnxruntime ship without type stubs; don't fail typecheck on the optional stack.
|
|
ignore_missing_imports = true
|
|
|
|
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["vision_service"]
|