- D-OCR Preview - A Complete OCR pipline for Bangla handwritten and printed document
D-OCR Preview - A Complete OCR pipline for Bangla handwritten and printed document
All four model components are included: the project layout checkpoint, project table-structure checkpoint, pretrained text detector, and trained SigLIP2/Qwen recognizer. This repository distributes the complete inference pipeline.
D-OCR is a modular Bangla OCR framework that combines document layout detection, text detection, table structure recognition and text recognition.
This release is intended for developers and researchers to test on their own Bangla documents and share feedback. A compatible NVIDIA GPU is recommended for interactive testing. CPU inference is supported, but it is currently slow, especially for long documents. Improving CPU efficiency is a development priority; this preview does not include a quantized or otherwise CPU-optimized recognizer.
What is included
This is a multi-model framework, not a single standalone OCR checkpoint:
| Component | Included weights | Role |
|---|---|---|
| Project Layout-S checkpoint | inference.pdiparams | Detect document regions and support reading order |
| Project Table Transformer checkpoint | model.safetensors | Recover table structure and cell geometry |
| Pretrained PP-OCRv5 mobile text detector | inference.pdiparams | Locate text for crop preparation |
| Trained SigLIP2 + connector + Qwen text recognizer | best.pt | Read text crops and table-cell text |
The pipeline handles crop preprocessing, layout-aware reading order, table reconstruction and text/HTML outputs. All weights and configuration assets are included. The API accepts images and PDFs and loads models locally.
See the pipeline on real documents
The left image is the input; the right image is the actual detection overlay returned by the published compiled runtime and weights on 25 November 2026. Blue boxes mark text regions, red numbers show output reading order, and orange boxes mark the recovered table region and cells. These are model outputs, with no manually corrected boxes or transcriptions.
Printed Bangla page
The pipeline returned 32 text regions. Detection does not imply perfect OCR: repetition stopping was triggered for two blocks in this run. Read the uncorrected OCR text.
Older, low-resolution print
The pipeline returned 25 text regions, including short poem lines and dense prose. Small or degraded glyphs remain difficult to recognize. Read the uncorrected OCR text.
Handwritten Bangla page
The pipeline returned 13 text regions and 554 text characters. Some boxes overlap; the example demonstrates execution and segmentation, not perfect layout or transcription accuracy. Read the uncorrected OCR text.
Table structure and cell text
This is a manually selected table crop, processed in table mode. The model
recovered 10 cells and recognized cell text. It does not demonstrate automatic
table localization on a full page. Some fallback text is duplicated in the raw
result, so table reconstruction still needs review.
Read the uncorrected OCR text.
Uploaded government form
The published pipeline returned 87 text regions and 4 regions classified as images on this uploaded document. Blue boxes show text, green boxes show image regions, and red numbers show output order. This is the unmodified model overlay. No semantic table grid was recovered in this page-mode run; the printed form lines are part of the input image. Read the uncorrected OCR text.
Document types tested
| Document / input type | Test coverage and observed limits |
|---|---|
| Clean printed Bangla pages | Current published pipeline; input and 32-region output shown above. OCR errors and repetition stopping remain possible. |
| Aged or low-resolution printed pages | Current published pipeline; input and 25-region output shown above. Small glyphs remain difficult. |
| Handwritten Bangla prose | Current published pipeline; input and 13-region output shown above, plus handwritten word/line evaluation in the 448-crop comparison. |
| Table and catalogue crops | Current pipeline recovered 1, 10 and 4 cells in three earlier selected crops; the refreshed 10-cell example is shown above. This is not a table-accuracy benchmark. |
| Forms mixing print, handwriting, stamps and signatures | Earlier seven-image web-app test; text was processed, but a semantic table grid was not detected. |
| Dense or stylized handwriting | Earlier seven-image test; some lines merged or were missed, with substantial recognition errors. |
| Tilted diary photos with mixed Bangla/English and occlusion | Earlier seven-image test; detection ran, while dates, English text and handwriting remained inaccurate. |
| Decorative calligraphy | Earlier seven-image test; text regions were detected, but the recognized words were wrong. |
| Image uploads and multi-page PDFs | Upload, page rendering, authentication and persistence have automated coverage. PDF routing tests use a stub evaluator and do not establish real-document OCR accuracy. |
Getting started
- Files needed: Download only
Dockerfile.gpu+compose.gpu.yml(GPU) orDockerfile.cpu+compose.cpu.yml(CPU), then follow USER_GUIDE.md. - Automatic setup: Docker downloads and verifies all model assets and the compiled Linux x86-64 / CPython 3.12 runtime during the build.
- No manual steps: No host Python installation, source checkout, or manual weight download is needed.
- Offline inference: Downloads are cached, so inference runs offline afterward.
- Not included: The original browser frontend and Python application source. The
/docspage provides a browser API testing interface instead.
Create API key
Create your private .env API key as shown in the USER_GUIDE.md, then start the service:
Run docker
# NVIDIA GPU
docker compose -f compose.gpu.yml up -d --build --wait --wait-timeout 600
# CPU
docker compose -f compose.cpu.yml up -d --build --wait --wait-timeout 600
Using the Swagger UI
- Open http://localhost:8000/docs.
- Click Authorize, paste your API key, then click Authorize and Close. You need to do this again after any page refresh.
- Click POST /v1/ocr to expand it, then click Try it out.
- Under Request body there's an image field with a Choose File button. Click it and pick your image (PNG or JPG) or PDF from your computer.
- Click Execute.
- Scroll down to Server response. You want 200 and the OCR result in JSON.
- Results include:
- Extracted text
- Region and table geometry
- Original-layout HTML
- Reading-order HTML
- The guide shows how to save and open both HTML views.
- Note: Reconstructions follow the backend's layout algorithm but are approximate. Fonts, spacing, and detected structure may differ from the input.
Using the Python script
- Create a script named ocr.py
import json import os import sys from pathlib import Path import requests from dotenv import load_dotenv API_URL = "http://localhost:8000/v1/ocr" # Load the .env that sits next to this script (utf-8-sig tolerates a BOM) load_dotenv(Path(__file__).with_name(".env"), encoding="utf-8-sig") def read_api_key() -> str: keys = os.getenv("OCR_API_KEYS") if not keys: sys.exit("OCR_API_KEYS not found in .env or environment") return keys.split(",")[0].strip() def main() -> None: if len(sys.argv) < 2: sys.exit("Usage: python ocr.py <image-or-pdf> [output.json]") file_path = Path(sys.argv[1]) out_path = Path(sys.argv[2] if len(sys.argv) > 2 else "ocr-result.json") if not file_path.is_file(): sys.exit(f"File not found: {file_path}") with file_path.open("rb") as f: resp = requests.post( API_URL, headers={"X-API-Key": read_api_key()}, files={"image": (file_path.name, f)}, timeout=1800, # CPU inference can be slow ) print(f"HTTP {resp.status_code}") if not resp.ok: sys.exit(resp.text) out_path.write_text( json.dumps(resp.json(), ensure_ascii=False, indent=2), encoding="utf-8" ) print(f"Saved response to {out_path}") if __name__ == "__main__": main() - How to run ocr.py in windows:
python3 -m venv .venv source .venv/Scripts/activate pip install requests python-dotenv python ocr.py "C:\path\to\test_bangla.png" python ocr.py "C:\path\to\doc.pdf" doc-result.json - How to run ocr.py in linux:
python3 -m venv .venv source .venv/bin/activate pip install requests python-dotenv python ocr.py ~/images/test_bangla.png python ocr.py ~/docs/doc.pdf doc-result.json
Model loading
- The recognizer is a custom architecture, so
AutoModel.from_pretrained(...)cannot currently loadbest.ptas a complete OCR framework. - Use the bundled runtime for end-to-end inference.
- No training or separate base-model download is needed.
Coming soon
- Support for llama.cpp, vLLM, OpenVINO, and ONNX Runtime.
Validation scope
The GPU recognition metrics below were measured with the local Python runtime on
an RTX 5060 Ti with 16 GB VRAM. CPU inference has also been exercised through the
compiled API. The staged compiled runtime and exported weights additionally
passed GPU warmup and a real-page check (13 blocks, text and both HTML views).
GPU-container execution has not yet been validated on this host,
which does not have NVIDIA Container Toolkit. See VALIDATION.md for the exact
standalone release checks and their status.
Local evaluation
The following is a local comparison on a fixed cohort of 448 labeled crops. It measures crop recognition, not end-to-end page or table accuracy.
| Metric | Previous VCA recognizer | Preview SigLIP2/Qwen recognizer |
|---|---|---|
| Character error rate | 9.57% | 4.90% |
| Word error rate | 23.45% | 14.53% |
| Exact crop match | 67.63% | 78.57% |
| Inference failures | 0 / 448 | 0 / 448 |
| Mean time per crop on the test GPU | 0.078 s | 0.203 s |
Measurements used an RTX 5060 Ti, four CPU threads and a caller cap of 512 output tokens. Model-loading time is excluded. Each backend retained its own crop-reading strategy: short spans for VCA, whole crops for the new recognizer. CER uses NFC-normalized Unicode code points; WER uses whitespace-separated words.
The cohort has been used in earlier project evaluation. Training manifests establishing independence from the supplied checkpoint's training data are not available in this release preparation. These numbers must not be interpreted as certified unseen-test performance, benchmark leadership or a general accuracy guarantee.
Performance varies by source. The new recognizer's CER was 12.62% on 32 external printed lines; WER was 27.83% on 64 BN-HTRD handwriting lines. The overall score therefore does not represent every document type equally.
In one CPU web-service test, a page producing 13 text blocks took approximately 80 seconds. The OCR container's peak cgroup memory was approximately 6.52 GiB, including charged file cache. These are single-sample measurements on the test PC, not minimum hardware requirements or throughput predictions for other CPUs.
Current limitations
- CPU performance is limited. Multi-page PDFs and dense pages may take substantial time. The current service processes one inference job at a time.
- Layout detection, reading order and table reconstruction remain experimental. Regions may be missed or assigned an incorrect order; tables may not yield a valid grid. Successful runtime checks do not establish table/grid accuracy.
- The inherited page pipeline applies OCR to at most 200 detected lines. Review returned warnings on dense pages.
- Text can be misread, omitted or repeated. Crop-dependent generation limits can truncate output. Repetition stopping can also shorten legitimate repeated text.
- Detection scores are not calibrated text-recognition confidence scores.
- The evaluation emphasizes Bangla. Broad multilingual performance, arbitrary mathematical notation and every handwriting style are not established.
- Default API upload limits are 16 MiB per file, 20 PDF pages, 144 DPI PDF rendering, and 20 megapixels per page.
- APIs, dependency pins and packaging may change during the preview period.
Review OCR output before using it as an authoritative transcription.
Development priorities
- Improve CPU latency and memory efficiency.
- Broaden independent evaluation of page layout, tables and text recognition.
- Improve reliability on difficult handwriting and dense document layouts.
- Simplify installation and provide a cleaner package interface.
Upstream components include SigLIP2,
Qwen3.5, PaddleOCR/PaddleX and Table Transformer.
Upstream licenses and notices are retained in THIRD_PARTY_NOTICES.md and licenses/.
Release license
D-OCR's own trained weight contributions and documentation use CC BY-NC 4.0. The compiled first-party framework runtime uses PolyForm Noncommercial 1.0.0. Noncommercial evaluation and research are permitted under those terms; commercial use requires separate permission. Third-party assets retain their upstream licenses. Read LICENSE and THIRD_PARTY_NOTICES.md for the scope and complete license texts. This is a noncommercial preview.









