Skip to content

Latest commit

Β 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”¬ Doctane by Zeross

Multimodal Intelligent Document Analysis and Understanding System

Stars Version License PyPI Downloads


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.


✨ Key Features

  • 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 WordGenerator to 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 Document objects (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 DocumentBuilder and hooks for custom post-processing
  • Multi-lingual Support: Features language detection and allows training with different vocabularies

🧬 Processing Pipeline

The pipeline processes documents through the following stages:

  1. Preprocessing: Handles page orientation detection and optional straightening
  2. Text Detection: A segmentation-based model (e.g., LinkNet) identifies word or line bounding boxes (both straight and rotated)
  3. Text Recognition: Crops from the detection stage are fed into a recognition model to transcribe the text
  4. Document Assembly: The final output is a structured Document object containing pages, blocks, lines, and words with their geometry and confidence scores. The system also supports Key Information Extraction (KIE)

πŸ—οΈ Supported Models

Detection Models

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

Recognition Models

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

πŸš€ Quick Start

One-Click Setup (Windows)

git clone https://github.com/Purushothaman-natarajan/doctane.git
cd doctane
run.bat

Manual Setup

# 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.py

Open http://localhost:8501 in your browser to use Doctane.


πŸ“– Documentation


πŸ“‚ Project Structure

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

πŸ’» Usage Examples

Python API

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)

Command Line

python scripts/run_inference.py \
    --input_dir data/raw \
    --output_dir results/outputs \
    --model_type seg_linknet_resnet50

πŸ“Š Supported Datasets

  • Custom Datasets: Easily train on your own data using the DetectionDataset and RecognitionDataset classes
  • Synthetic Data: The WordGenerator can create arbitrary amounts of training data
  • Public Datasets (Planned): FUNSD, PubLayNet, DocVQA

πŸ› οΈ Training

Text Detection

python train/text_detection/train_detection.py \
    --config configs/detection.yaml \
    --epochs 100

Text Recognition

python train/text_recognition/train_recognition.py \
    --config configs/recognition.yaml \
    --epochs 50

Distributed Training (DDP)

torchrun --nproc_per_node=4 \
    train/text_detection/train_detection_ddp.py \
    --config configs/detection.yaml

πŸ”§ Configuration

Key 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

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Make changes and add tests
  4. Run linting and type checking
  5. Submit a pull request

πŸ“ˆ Future Roadmap

  • End-to-end document captioning
  • Visual layout annotation
  • Web Dashboard for interaction
  • Multi-language support expansion
  • PDF export functionality

πŸ™ Acknowledgments

  • Hugging Face LayoutLM, Donut, doctr
  • Tesseract OCR, EasyOCR
  • pytorch-segmentation-models
  • PyMuPDF, PDFPlumber

πŸ“œ License

Apache License 2.0 - See LICENSE for details.


πŸ‘¨β€πŸ’» Developer

Purushothaman Natarajan


Made with ❀️ by Doctane

About

OCR models built on top of pytorch.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages