Projects / AI/ML / 2024
AI Document Processing Demo
OCR + LayoutLM Extraction
95%+ OCR Accuracy
96% Classification
LayoutLM Model
100+ tested Documents
4 stages Pipeline
95% accuracy Extraction
Developed intelligent document processing (IDP) demo automating data extraction from unstructured documents using computer vision and NLP. Pipeline: image preprocessing (deskew, denoise) → Tesseract OCR → document classification (ResNet50 CNN) → field extraction (LayoutLM transformer) → validation. LayoutLM understands document layout via position embeddings enabling extraction from variable invoice formats. FastAPI backend processes uploads, React frontend displays extracted fields with confidence scores. Demonstrates production IDP patterns for invoice processing, form digitization.
The challenge
Document processing requires OCR for text extraction, layout understanding for field identification, classification for document types. Tesseract OCR needs preprocessing (deskew, denoise). Variable invoice layouts defeat template matching. LayoutLM transformer understands positional context. Need validation and confidence scores.
Implementation
Built multi-stage pipeline: OpenCV preprocessing → Tesseract OCR → ResNet50 classification → LayoutLM field extraction → rule validation. LayoutLM pre-trained on document layouts extracts fields via position embeddings. FastAPI backend, React frontend with drag-drop upload. Confidence scores flag low-quality extractions for review.
Architecture
- Multi-stage pipeline: preprocessing → OCR → classification → extraction
- OpenCV preprocessing: deskew, denoise, binarization
- Tesseract 5.3 OCR with language models
- ResNet50 CNN for document type classification
- LayoutLM transformer for position-aware field extraction
- spaCy NER for vendor name and address extraction
- FastAPI async endpoints with Celery background tasks
- Redis task queue for async document processing
- React frontend with drag-drop and extracted field display
- Docker Compose: FastAPI + Celery + Redis + PostgreSQL
Features
- OpenCV 4.9 preprocessing: deskew, denoise, binarization, adaptive thresholding
- Tesseract 5.3 OCR with eng+multi language data
- ResNet50 CNN document classifier trained on 10 document types
- LayoutLM-base transformer for position-aware field extraction
- Table detection and parsing using image processing techniques
- Named entity recognition with spaCy for vendor names, addresses
- Business rule validation: amount format, date validation, required fields
- FastAPI 0.109 async endpoints with Celery task queue
- React 18 frontend with drag-drop upload and extracted field display
- Confidence score thresholding for human review flagging
- Redis 7.2 for task queue and result caching
- Docker Compose deployment: FastAPI + Celery + Redis + PostgreSQL
Results
- Multi-stage pipeline: preprocessing → OCR → classification → extraction → validation
- Tesseract 5.3 OCR with OpenCV preprocessing (deskew, denoise, binarization)
- ResNet50 CNN document classifier: 96% accuracy across 10 document types
- LayoutLM-base field extraction: 95% accuracy on invoice test set
- Processes invoices, receipts, forms extracting vendor, amount, date, line items
- FastAPI backend with async upload processing and Redis task queue
- React 18 frontend with drag-drop, extracted field display, confidence scores
- Tested with 100+ invoice samples from various formats
Technologies
- Tesseract 5.3
- OpenCV 4.9
- PyTorch 2.2+
- Hugging Face Transformers
- LayoutLM
- Python 3.11+
- FastAPI 0.109
- Celery
- Redis 7.2
- PostgreSQL 16
- React 18
- TypeScript 5.x
- spaCy 3.7
- Pillow
- NumPy
- Docker 24.0