Skip to content
ryanzniePublic

Latest commit

 

History

308 Commits

Folders and files

Repository files navigation

Invoice NER

Invoice NER extracts invoice numbers from invoice images with heuristics and a local LayoutLMv3 ONNX model, with OpenRouter as an optional fallback. Set OPENROUTER_API_KEY to enable the fallback. It includes a FastAPI API, a Gradio upload demo, and a Next.js invoice review frontend.

Run locally

Requires Python 3.10+ and uv. The large ONNX model is managed outside Git; make it available at the configured model path before starting.

uv sync --extra dev
cp .env.example .env
uv run python -m src.demo --host 127.0.0.1

Open http://127.0.0.1:7860/ for the upload UI or http://127.0.0.1:7860/docs for the API.

To upload a sample invoice and OCR JSON file:

curl -F 'image=@invoice.jpg' -F 'ocr_file=@ocr.json' http://127.0.0.1:7860/predict

Tests

uv run pytest

See Testing for contract and container checks.

Documentation

Demo

Upload a receipt, review the invoice number, then confirm or copy it.

Invoice review demo

See the empty and mobile layouts

Empty upload state

Invoice review on a mobile viewport

Repository structure

src/                 API, upload UI, and inference
scripts/             Training, preprocessing, and model export
deploy/              Dockerfiles and Runpod worker setup
frontend/            Next.js invoice review app
tests/               Pytest, end-to-end, and load tests
data/  models/        Datasets and model files
docs/  monitoring/    Guides and production monitoring
benchmarks/           Model evaluation
notebooks/            Exploration and analysis
triton_model_repo/    Triton model configuration

Releases

Packages

Contributors

Languages