aamijar/muharaf-public
Viewer • Updated • 24.5k • 419 • 21
Arabic handwritten-text recognition model: Qwen/Qwen3-VL-2B-Instruct fine-tuned with LoRA (merged) on
historical handwritten Arabic manuscript lines from aamijar/muharaf-public.
| Test split | CER | WER |
|---|---|---|
| Base model (zero-shot, n=300) | 1.1281 | 1.1144 |
| Raqim-OCR (n=1334) | 0.1737 | 0.4494 |
Input: one cropped text-line image. Output: the Arabic transcription. Peak training VRAM: 10.9 GB.
from transformers import AutoModelForImageTextToText, AutoProcessor
from PIL import Image
repo = "Youssefx64/Raqim_OCR_Arabic"
processor = AutoProcessor.from_pretrained(repo)
model = AutoModelForImageTextToText.from_pretrained(repo, dtype="auto", device_map="auto")
prompt = processor.apply_chat_template(
[{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "Transcribe the Arabic handwriting in this image exactly as written."}]}],
add_generation_prompt=True, tokenize=False)
enc = processor(text=[prompt], images=[Image.open("line.png").convert("RGB")], return_tensors="pt").to(model.device)
out = model.generate(**enc, max_new_tokens=160, do_sample=False)
print(processor.batch_decode(out[:, enc["input_ids"].shape[1]:], skip_special_tokens=True)[0])
Trained on Muharaf (Saeed et al., 2024), released under CC BY-NC-SA 4.0, so this model is non-commercial, share-alike. Please cite: Muharaf: Manuscripts of Handwritten Arabic Dataset for Cursive Text Recognition (arXiv:2406.09630).
Trained on line-level crops of historical manuscripts; full pages need a line-segmentation step first. Modern print and other scripts are out of scope.