Multimodal Intelligent Document Analysis and Understanding System
Doctane is a vision-language-based pipeline built to automate document analysis, including OCR, layout understanding, semantic extraction, and captioning β all under one modular framework. Designed for business documents, forms, invoices, and scanned reports.
- End-to-End OCR: Unified pipeline for text detection and recognition
- Robust Detection: Handles both straight and rotated text using segmentation-based models
- Accurate Recognition: High-accuracy text recognition with support for custom vocabularies
- Synthetic Data Generation: Includes
WordGeneratorto create training data on-the-fly - Layout-Aware: Automatically detects page orientation and can straighten pages before analysis
- Structured Output: Exports results as rich, hierarchical
Documentobjects (Page, Block, Line, Word) and supports hOCR format - Distributed Training: Comes with
DDP(Distributed Data Parallel) scripts for faster training on multiple GPUs - Extensible: Modular design with a
DocumentBuilderand hooks for custom post-processing - Multi-lingual Support: Features language detection and allows training with different vocabularies
The pipeline processes documents through the following stages:
- Preprocessing: Handles page orientation detection and optional straightening
- Text Detection: A segmentation-based model (e.g., LinkNet) identifies word or line bounding boxes (both straight and rotated)
- Text Recognition: Crops from the detection stage are fed into a recognition model to transcribe the text
- Document Assembly: The final output is a structured
Documentobject containing pages, blocks, lines, and words with their geometry and confidence scores. The system also supports Key Information Extraction (KIE)
| Model | Description |
|---|---|
| LinkNet | Fast and lightweight segmentation |
| DeepLabV3+ | High accuracy for complex layouts |
| SegFormer | State-of-the-art transformer-based |
| Faster R-CNN | Region-based detection |
| Model | Description |
|---|---|
| SAR | Sequence Approximation Recognition |
| ViTSTR | Vision Transformer for STR |
| CRNN | CNN + RNN + CTC |
| TrBA | Transformer-based Recognition |
| MASTER | Multi-Aspect Self-Attention |
| ABINet | Attention-based Iterative Network |
| VisionLAN | Vision-Language Awareness Network |
| DiT | Diffusion Transformer |
git clone https://github.com/Purushothaman-natarajan/doctane.git
cd doctane
run.bat# Clone the repository
git clone https://github.com/Purushothaman-natarajan/doctane.git
cd doctane
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
pip install -e .
# Run the web interface
streamlit run app.pyOpen http://localhost:8501 in your browser to use Doctane.
- Documentation - Comprehensive API and usage guide
- Architecture - System design and component details
- Developer Guide - Setup, training, and contribution guide
- Profile - Developer information
Doctane/
βββ index.html # Landing page
βββ docs.html # Documentation
βββ architecture.html # System architecture
βββ developer-guide.html # Developer guide
βββ profile.html # Developer profile
βββ app.py # Streamlit web interface
βββ run.bat # Windows launcher
β
βββ doctane/ # Main package
β βββ predictor/ # Predictor classes
β βββ ocr_pipeline/ # OCR pipeline
β βββ models/ # Model definitions
β β βββ detection/ # Detection models
β β βββ recognition/ # Recognition models
β β βββ classification/ # Classification models
β βββ datasets/ # Dataset loaders
β βββ train/ # Training scripts
β βββ utils/ # Utilities
β βββ evaluate/ # Evaluation
β
βββ configs/ # YAML configurations
βββ data/ # Data directory
βββ scripts/ # Utility scripts
βββ tests/ # Unit tests
βββ notebooks/ # Jupyter notebooks
βββ requirements.txt # Dependencies
import numpy as np
from PIL import Image
from doctane.ocr_pipeline.ocr_predictor import OCRPredictor
# Load image
image = Image.open("document.jpg").convert("RGB")
np_image = np.array(image)
# Run OCR
predictor = OCRPredictor()
output = predictor([np_image])
# Access results
for page in output.pages:
print(page)python scripts/run_inference.py \
--input_dir data/raw \
--output_dir results/outputs \
--model_type seg_linknet_resnet50- Custom Datasets: Easily train on your own data using the
DetectionDatasetandRecognitionDatasetclasses - Synthetic Data: The
WordGeneratorcan create arbitrary amounts of training data - Public Datasets (Planned): FUNSD, PubLayNet, DocVQA
python train/text_detection/train_detection.py \
--config configs/detection.yaml \
--epochs 100python train/text_recognition/train_recognition.py \
--config configs/recognition.yaml \
--epochs 50torchrun --nproc_per_node=4 \
train/text_detection/train_detection_ddp.py \
--config configs/detection.yamlKey environment variables:
| Variable | Description | Default |
|---|---|---|
BUILD_VERSION |
Package version | 0.1.0a0 |
CHECKPOINT_DIR |
Model checkpoints | ./checkpoints |
DATA_DIR |
Training data | ./data |
LOG_DIR |
Training logs | ./logs |
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Make changes and add tests
- Run linting and type checking
- Submit a pull request
- End-to-end document captioning
- Visual layout annotation
- Web Dashboard for interaction
- Multi-language support expansion
- PDF export functionality
- Hugging Face
LayoutLM,Donut,doctr - Tesseract OCR, EasyOCR
- pytorch-segmentation-models
- PyMuPDF, PDFPlumber
Apache License 2.0 - See LICENSE for details.
Purushothaman Natarajan
- GitHub: @Purushothaman-natarajan
- Portfolio: purushothaman-natarajan.github.io
- Email: purushothamanprt@gmail.com
Made with β€οΈ by Doctane