Layout-aware document classification, information extraction, and visual QA using LayoutLMv3.
PDF/Image Upload
│
▼
Tesseract OCR ──────────────────────┐
│ │
▼ │
LayoutLMv3 Classifier words + boxes
(Document Type) │
│ ▼
│ LayoutLMv3 Extractor
│ (Named Entity Recognition)
│ │
└──────────────────────────────┤
▼
DocVQA Pipeline
(Question Answering)
│
▼
Streamlit Interface
| Feature | Model | Dataset |
|---|---|---|
| Document Classification | LayoutLMv3 | RVL-CDIP (400K docs, 16 classes) |
| Information Extraction | LayoutLMv3 | FUNSD (form understanding) |
| Document QA | impira/layoutlm-document-qa | DocVQA |
| OCR | Tesseract OCR | — |
# Install Tesseract (system)
sudo apt-get install tesseract-ocr # Linux
brew install tesseract # macOS
# Install Python dependencies
pip install -r requirements.txtstreamlit run app.py- Upload
notebooks/train_classifier.ipynbto Kaggle - Enable GPU (T4 — free tier)
- Run all cells
- Download checkpoint to
models/classifier_checkpoint/ - Update
configs/config.yaml→checkpoint_path
docintel/
├── app.py # Streamlit UI
├── requirements.txt
├── configs/
│ └── config.yaml # All hyperparameters & paths
├── src/
│ ├── ocr/
│ │ └── pipeline.py # Tesseract + pdf2image
│ ├── classification/
│ │ └── classifier.py # LayoutLMv3 for doc classification
│ ├── extraction/
│ │ └── extractor.py # LayoutLMv3 for NER/IE
│ ├── qa/
│ │ └── document_qa.py # DocVQA pipeline
│ └── utils/
│ └── helpers.py # Shared utilities
├── notebooks/
│ └── train_classifier.ipynb # Kaggle training notebook
└── models/
├── classifier_checkpoint/ # Fine-tuned weights (after training)
└── extractor_checkpoint/ # Fine-tuned weights (after training)
Local machine (16GB RAM, Intel Iris Xe):
- Code development, testing, inference
- Run
streamlit run app.pywith pretrained models
Kaggle (Tesla T4 GPU):
- Fine-tune LayoutLMv3 on RVL-CDIP (~6-8 hours for full training)
- Fine-tune LayoutLMv3 on FUNSD (~2-3 hours)
- Export checkpoints → store in
models/
Hugging Face Spaces:
- Deploy
app.py+ push model weights to HF Hub - Update
config.yamlhf_hub_modelfields
| Task | Metric | Target |
|---|---|---|
| Classification | Accuracy | >90% |
| Classification | Weighted F1 | >88% |
| Extraction | Entity F1 | >75% |
| QA | Exact Match | >65% |
| QA | F1 | >75% |
- RVL-CDIP:
aharley/rvl_cdipon HF Hub (~35GB) - FUNSD:
nielsr/funsdon HF Hub - DocVQA:
docvqaon HF Hub
PyTorch • Hugging Face Transformers • LayoutLMv3 • Tesseract OCR
Streamlit • Plotly • Pandas • NumPy • OpenCV • pdf2image
Built a ML project demonstrating Computer Vision, NLP, OCR, and Transformer-based document understanding.