| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/arni-solutions.de/web/plate-ai-api/ |
Upload File : |
#!/usr/bin/env python3
"""CLI-Testtool – Erkennung direkt auf einer lokalen Bilddatei (ohne API/DB).
python test_recognition.py /pfad/zum/bild.jpg
python test_recognition.py /pfad/zum/bild.jpg --pretty
Gibt das JSON-Ergebnis der Pipeline aus. Ideal zum schnellen Pruefen der
Modelle/Postprocessing auf dem Server.
"""
import json
import sys
import uuid
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from app.config import settings # noqa: E402
from app.services import image_service # noqa: E402
from app.services.recognition_pipeline import get_pipeline # noqa: E402
def main() -> int:
args = [a for a in sys.argv[1:] if not a.startswith("--")]
if not args:
print("Usage: python test_recognition.py <bild> [--pretty]")
return 2
img_path = Path(args[0])
if not img_path.exists():
print(f"Datei nicht gefunden: {img_path}")
return 2
raw = img_path.read_bytes()
try:
prepared = image_service.prepare_image(
raw,
allowed_types=settings.allowed_image_types_list,
max_dimension=settings.max_image_dimension,
min_dimension=settings.min_image_dimension,
)
except image_service.ImageValidationError as exc:
print(json.dumps({"success": False, "error": "invalid_image", "detail": str(exc)}))
return 1
response = get_pipeline().run(prepared.rgb, request_id=str(uuid.uuid4()))
indent = 2 if "--pretty" in sys.argv else None
print(json.dumps(response.model_dump(), ensure_ascii=False, indent=indent))
return 0
if __name__ == "__main__":
raise SystemExit(main())