indic-ocr-mlx / weights /ocr /README.md
HashNuke's picture
Clarify IndicOCR usage and stage loading
3ca5518 verified
|
Raw
History Blame Contribute Delete
2.12 kB
metadata
tags:
  - mlx
  - ocr
  - indic
library_name: mlx-vlm
pipeline_tag: image-text-to-text
license: other
license_name: indic-open-model-license-1.0
license_link: https://huggingface.co/HashNuke/indic-ocr-mlx/blob/main/LICENSE.md
base_model: bodhan-ai/indic-ocr

IndicBlockOCR (MLX)

Built with IndicBlockOCR from Bodhan AI / AI4Bharat.

The recognition stage of IndicOCR (MLX): a Qwen3.5-0.8B fine-tune for transcribing text, equations, and tables from cropped document regions. The weights are BF16 (1.7 GB), not quantized.

Use an mlx-vlm checkout with indic_ocr support. Replace crop.png with an image of a text region, not a complete multi-region page:

from pathlib import Path

from huggingface_hub import snapshot_download
from PIL import Image
from mlx_vlm import generate, load
from mlx_vlm.models.indic_ocr.processing_indic_ocr import area_clamp, prompt_for
from mlx_vlm.prompt_utils import apply_chat_template

root = Path(snapshot_download(
    "HashNuke/indic-ocr-mlx", allow_patterns=["weights/ocr/*"]
))
model, processor = load(str(root / "weights/ocr"))
with Image.open("crop.png") as image:
    crop = area_clamp(image.convert("RGB"))
prompt = apply_chat_template(
    processor, model.config, prompt_for("Text"), num_images=1
)
result = generate(
    model, processor, prompt, [crop],
    max_tokens=2048, temperature=0.0, verbose=False,
)
print(result.text)

Use prompt_for("Equation") for LaTeX or prompt_for("Table") for HTML tables. Greedy decoding (temperature=0.0) matches the default page pipeline.

The repository root is a two-stage wrapper: load("HashNuke/indic-ocr-mlx") does not load this OCR stage. Use the local weights/ocr path above, or IndicOCRParser.from_pretrained("HashNuke/indic-ocr-mlx") for complete pages, as shown in the main model card.

The source weights are from bodhan-ai/indic-ocr under the Indic Open Model License v1.0.