A fully local, privacy-preserving OCR pipeline for pre-submission validation of Albanian municipal documents.
Built as a Bachelor thesis at Epoka University, Faculty of Engineering, Department of Software Engineering (2026).
Albanian citizens applying for municipal services must upload scanned or photographed documents that are reviewed manually by staff — a process that takes 3–5 business days and often ends in rejection due to problems that could have been caught instantly.
AMI validates documents in real time before submission:
- Explains required documents for each service
- Accepts photos, scans, or PDFs
- Runs OCR to extract structured fields automatically
- Validates identity, completeness, and legal eligibility
- Returns instant feedback before any file reaches municipal staff
| Service | Documents Required | Decision |
|---|---|---|
| Housing Subsidy (Law 22/2018) | ID Card · Salary Certificate · Lease Contract | Eligibility + S = Qr − (A × Ap) |
| Punësim Privat | ID Card · Formular Aplikimi | Identity valid + form complete |
| Vërtetim Vjetërsie në Punë | ID Card · ISSH Certificate | Currency check + years of service |
Upload → Decode → Classify → Adaptive Threshold ↓ Verdict ← Cross-Validate ← Extract ← OCR Inference
Three OCR backends, routed per document type:
- Qwen2-VL-2B-Instruct (HuggingFace, 4-bit NF4, GPU)
- EasyOCR (CRAFT + CRNN, CPU)
- LLaVA-7B (Ollama, local HTTP)
Routing formula: R(d) = argmax MCEF(m, p, d)
| Metric | Value |
|---|---|
| Adaptive Orchestrator MCEF | 1.80 |
| Best uniform baseline MCEF | 1.69 |
| Improvement over worst baseline | +25.9% |
| False Reject Rate | 0% |
| False Accept Rate | 35.3% (date-field extraction on noisy ID cards) |
Backend: Python · FastAPI · HuggingFace Transformers · OpenCV · EasyOCR · Ollama · RapidFuzz
Frontend: Vanilla JavaScript · Tailwind CSS
Models: Qwen2-VL-2B-Instruct · EasyOCR · LLaVA-7B
All inference runs entirely on local hardware. No document image, extracted field, or citizen identifier is transmitted to any external server. No internet connection required during inference. LGDP compliant.
- Python 3.10+
- NVIDIA GPU with ≥8GB VRAM (for Qwen2-VL-2B)
- Ollama installed and running locally (for LLaVA-7B)
- Two Python virtual environments (see below)
# Clone the repository
git clone https://github.com/bdurmishi23/AMI-Municipal-Assistant
cd AMI-Municipal-Assistant
# Backend virtual environment
python -m venv .venv
.venv\Scripts\activate
pip install fastapi uvicorn opencv-python pillow rapidfuzz easyocr
# ML virtual environment
python -m venv .venv_ml
.venv_ml\Scripts\activate
pip install torch transformers bitsandbytes accelerate
# Run the server
.venv\Scripts\activate
python main.py