2023CompletedComputer Vision
Text Extraction from Store Bills

Metrics & Visuals
9
Fields Extracted
JPG / PNG
Formats Supported
MySQL
Storage
Diagram
Pipeline overview. App screenshots coming soon.
Overview
An end-to-end Streamlit application that extracts structured data from invoice images using EasyOCR, parses fields with regex, persists results in MySQL, and evaluates accuracy using Levenshtein distance. The pipeline handles the full lifecycle from raw bill image to queryable structured database records.
Key Features
- Upload invoice images in JPG, JPEG, PNG formats via Streamlit UI
- EasyOCR with English language model for robust text extraction from bill images
- Regex-based structured field parsing: Invoice Number, Date, Products, Quantity, Rate, Value, CGST, SGST, Total GST
- SQLAlchemy ORM with auto table creation for MySQL persistence
- Interactive DataFrame view of all extracted fields in the browser
- Levenshtein distance-based accuracy evaluation against ground truth
- Wand (ImageMagick) for image preprocessing: deskewing, thresholding, denoising
- Unit tests with pytest for parser and accuracy modules
How It Works
- 1Streamlit UI (app.py) → user uploads invoice image
- 2ocr_engine.py: PIL opens image → EasyOCR reads raw text
- 3parser.py: Regex extracts structured invoice fields → InvoiceData dataclass
- 4database.py: SQLAlchemy inserts structured data into MySQL
- 5accuracy.py: Levenshtein distance compares extracted vs ground truth
- 6Results displayed as interactive DataFrame in the Streamlit browser UI
System Architecture
Input
Invoice Image
JPG / PNG upload
Preprocessing
Wand (ImageMagick)
Deskew, threshold, denoise
OCR
EasyOCR
English text extraction
Parsing
Regex Parser
Structured field extraction
InvoiceData
Typed dataclass
Storage & Eval
MySQL
SQLAlchemy ORM
Accuracy Module
Levenshtein distance
UI
Streamlit
Interactive DataFrame
Data Flow
EasyOCR→Regex Parser(raw text)
Roadmap
- PDF invoice support
- Multi-language OCR
- Batch upload for multiple invoices at once
- Export to Excel / CSV
- Docker containerization
- REST API endpoint (FastAPI)
Tech Stack
OCR & Vision
EasyOCR 1.7Pillow 10Wand (ImageMagick)OpenCV
Backend
Python 3.10Streamlit 1.32SQLAlchemy 2.0PyMySQL
Database
MySQL 8.0
Testing
pytesteditdistance (Levenshtein)python-dotenv