DataTrove-native OCR pipeline for processing PDF documents with a server-backed vision model.
This repository focuses on a working local OCR pipeline and a monitoring UI, with scaffolding for Azure ingestion and postprocessing stages.
Working pieces:
- PDF reader
- OCR inference via DataTrove
InferenceRunner(server-backed endpoint) - JSONL output writer
- Progress + record monitor UI (
OCRInferenceProgressMonitor)
Scaffolded / placeholder (not implemented yet):
- Azure ingestion (
AzureManifestReader,AzureFetchPDF) - Page regrouping (
GroupPages) - Postprocess blocks (
LanguageTag,BoilerplateRemover) - Quality scoring (
BertQualityScore) - Stage scripts in
scripts/(config loading and pipeline builders are TODO)
- Install dependencies:
uv pip install -e .-
Start your OCR server (OpenAI-compatible chat/completions endpoint).
-
Run the local pipeline with a config file:
python tewe.py reader.backend=azure \
reader.azure.container_path=az://mycontainer \
reader.input_dir="mypdfdir" \
ocr.server_url=http://127.0.0.1:8080 \
ocr.model_name=mradermacher/KarantaOCR-GGUF \
output.output_dir=outputsA ready-to-edit sample lives here:
configs/tewe.yaml
Required keys for tewe.py:
limitmonitorjob_nameocr.server_urlocr.model_nameoutput.output_diroutput.output_filenamereader.input_dir
Enable monitoring in the config:
monitor: trueThe monitor runs by default on:
http://127.0.0.1:8040
It exposes:
/list view/record?record_id=...detail view
The UI is served from:
itewe/monitoring/ui/index.htmlitewe/monitoring/ui/record.html
configs/
tewe.yaml
itewe/
blocks/
assemble/
group_pages.py # placeholder
postprocess/
boilerplate.py # placeholder
language_tag.py # placeholder
quality/
bert_score.py # placeholder
monitoring/
tracker.py # active (UI + progress API)
ui/
index.html
record.html
readers/
pdf.py # active
ids.py # active (ID helpers)
utils.py # active (PDF + rollout helpers)
tewe.py # config-driven local runner
scripts/ # stage scripts (scaffolded)-
itewe/utils.py:- PDF rendering + request building for OCR.
rollout_postprocesscreates OpenAI-style multimodal payloads.
-
itewe/monitoring/tracker.py:- Progress tracking + web UI with per-page request/output inspection.
-
itewe/ids.py:- Stable doc/page ID helpers.
pytestTBD