Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AMI — Adaptive Municipal Intelligence

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).


What It Does

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

Supported Services

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

System Architecture

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)


Key Results

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)

Tech Stack

Backend: Python · FastAPI · HuggingFace Transformers · OpenCV · EasyOCR · Ollama · RapidFuzz

Frontend: Vanilla JavaScript · Tailwind CSS

Models: Qwen2-VL-2B-Instruct · EasyOCR · LLaVA-7B


Privacy

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.


Requirements

  • 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)

Setup

# 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

About

A fully local OCR pipeline for pre-submission validation of Albanian municipal documents. Built with Qwen2-VL-2B, EasyOCR, FastAPI, and JavaScript.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages