Manazir OCR — Arabic-first, optics-inspired multi-model OCR. Extracts high-quality text and layout (HTML/Markdown) from Arabic documents using pluggable backends (Qari, DIMI, OCR-RL2, TrOCR, Qwen2/VL, PaddleOCR Arabic, Surya, and optional APIs). Includes CLI and Streamlit UIs
43
stars
19
commits
Python
primary language
Nov 2, 2025
updated
Manazir OCR — Arabic optics‑inspired multi‑model OCR

Manazir OCR is an Arabic‑first, layout‑aware OCR framework inspired by Ibn al‑Haytham’s Kitāb al‑Manāẓir (Book of Optics). It orchestrates multiple backends (local Transformers, vLLM servers, lightweight engines, and commercial APIs) to extract high‑quality text from PDFs and images, producing Markdown/HTML with layout blocks and figure crops.
Install from source (recommended):
python -m venv venv
source venv/bin/activate # on Windows: venv\Scripts\activate
pip install -U pip
pip install -e .
Run the CLI:
# Batch processing with layout-aware pipeline (vLLM or HF)
manazir process <input_path> <output_dir> --method vllm --paginate_output
# Arabic-first single-file OCR with model selection
manazir ocr file.pdf --language ar --quality highest --device cuda
# Browse models and get recommendations
manazir list-available-models
manazir recommend --language ar --document-type handwritten
Launch the apps:
manazir_app # Basic demo (choose Classic hf/vllm or pick a Registry model)
manazir_app_pro # Professional UI (toggle Nerd Theme in sidebar)
manazir_app_pro
# then open http://localhost:8501
Alternative:
python -m docustruct.scripts.run_app_professional
# Convert a PDF to Markdown using Arabic-first defaults
manazir ocr input.pdf --language ar --output out_dir
# List models and pick one
manazir list-available-models
manazir ocr input.png --language ar --model qwen2_vl_2b
qari_ocr, dimi_arabic_ocr, ocr_rl2, trocr_arabicqwen2_vl_2b, qwen2_5_vl_7b_arabicpaddle_ocr_arabic, paddle_ocr_arabic_v4, tesseract, easy_ocrsurya_ocr, surya_ocr_arabicopenai_gpt4o, mistral_ocrAdditions in this repo: qwen2_5_vl_7b_arabic, paddle_ocr_arabic_v4, surya_ocr_arabic, qari_ocr_waraqon.

from docustruct.model import create_model
from PIL import Image
model = create_model("qwen2_5_vl_7b_arabic", device="cuda")
img = Image.open("page.png").convert("RGB")
result = model.process_image(img)
print(result.text)
The CLI’s vLLM path uses OpenAI‑compatible endpoints. Configure via env:
export VLLM_API_KEY=EMPTY
export VLLM_API_BASE=http://localhost:8000/v1
export VLLM_MODEL_NAME=manazir
docustruct.* for now; package name is manazir-ocr.paddleocr). Commercial APIs need keys and may incur costs.assets/.assets/screenshot-ui.png, assets/screenshot-available-models.png.Developed by Hesham Haroon — contact: heshamharoon19@gmail.com.
Code is Apache‑2.0. Some integrated models (e.g., Surya) are GPL‑3.0; verify licenses before use.
19 commits
Python
89.6%
HTML
10.4%
Manazir OCR — Arabic-first, optics-inspired multi-model OCR. Extracts high-quality text and layout (HTML/Markdown) from Arabic documents using pluggable backends (Qari, DIMI, OCR-RL2, TrOCR, Qwen2/VL, PaddleOCR Arabic, Surya, and optional APIs). Includes CLI and Streamlit UIs
43
stars
19
commits
Python
primary language
Nov 2, 2025
updated
Manazir OCR — Arabic optics‑inspired multi‑model OCR

Manazir OCR is an Arabic‑first, layout‑aware OCR framework inspired by Ibn al‑Haytham’s Kitāb al‑Manāẓir (Book of Optics). It orchestrates multiple backends (local Transformers, vLLM servers, lightweight engines, and commercial APIs) to extract high‑quality text from PDFs and images, producing Markdown/HTML with layout blocks and figure crops.
Install from source (recommended):
python -m venv venv
source venv/bin/activate # on Windows: venv\Scripts\activate
pip install -U pip
pip install -e .
Run the CLI:
# Batch processing with layout-aware pipeline (vLLM or HF)
manazir process <input_path> <output_dir> --method vllm --paginate_output
# Arabic-first single-file OCR with model selection
manazir ocr file.pdf --language ar --quality highest --device cuda
# Browse models and get recommendations
manazir list-available-models
manazir recommend --language ar --document-type handwritten
Launch the apps:
manazir_app # Basic demo (choose Classic hf/vllm or pick a Registry model)
manazir_app_pro # Professional UI (toggle Nerd Theme in sidebar)
manazir_app_pro
# then open http://localhost:8501
Alternative:
python -m docustruct.scripts.run_app_professional
# Convert a PDF to Markdown using Arabic-first defaults
manazir ocr input.pdf --language ar --output out_dir
# List models and pick one
manazir list-available-models
manazir ocr input.png --language ar --model qwen2_vl_2b
qari_ocr, dimi_arabic_ocr, ocr_rl2, trocr_arabicqwen2_vl_2b, qwen2_5_vl_7b_arabicpaddle_ocr_arabic, paddle_ocr_arabic_v4, tesseract, easy_ocrsurya_ocr, surya_ocr_arabicopenai_gpt4o, mistral_ocrAdditions in this repo: qwen2_5_vl_7b_arabic, paddle_ocr_arabic_v4, surya_ocr_arabic, qari_ocr_waraqon.

from docustruct.model import create_model
from PIL import Image
model = create_model("qwen2_5_vl_7b_arabic", device="cuda")
img = Image.open("page.png").convert("RGB")
result = model.process_image(img)
print(result.text)
The CLI’s vLLM path uses OpenAI‑compatible endpoints. Configure via env:
export VLLM_API_KEY=EMPTY
export VLLM_API_BASE=http://localhost:8000/v1
export VLLM_MODEL_NAME=manazir
docustruct.* for now; package name is manazir-ocr.paddleocr). Commercial APIs need keys and may incur costs.assets/.assets/screenshot-ui.png, assets/screenshot-available-models.png.Developed by Hesham Haroon — contact: heshamharoon19@gmail.com.
Code is Apache‑2.0. Some integrated models (e.g., Surya) are GPL‑3.0; verify licenses before use.
19 commits
Python
89.6%
HTML
10.4%