Downloads · 30 days
10
1% of all-time downloads
AhmedZaky1/DIMI-Arabic-OCR-V2
DIMI-Arabic-OCR-V2 is a image-text-to-text model from AhmedZaky1. Use it for the image-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
Downloads · 30 days
10
1% of all-time downloads
All-time downloads
1.3K
Public
Repo size
218 MB
Likes
1
Public
Click a slice to open those files.
.safetensors206 MB · 93%
From the Hugging Face model README
Accurate Arabic OCR model V2 for extracting printed Arabic text from images
</div>DIMI Arabic OCR v2 is a specialized Arabic Optical Character Recognition model fine-tuned on Qwen2.5-VL-7B-Instruct using LoRA adapters. This is the second iteration, building upon v1 with improved diacritics handling and enhanced accuracy across diverse Arabic text scenarios.
✅ 30% reduction in WER on diacritics-heavy text
✅ Enhanced training dataset with balanced diacritics representation
✅ Improved generalization across news articles and formal documents
✅ Better preservation of text formatting and structure
| Metric | Score | Description |
|---|---|---|
| WER | 0.3049 | Word Error Rate (↓ lower is better) |
| CER | 0.1119 | Character Error Rate (↓ lower is better) |
| Perfect Predictions | 23% | Exact matches with ground truth |
| Metric | Score |
|---|---|
| WER | 0.2315 |
| CER | 0.0776 |
| Model | Test WER | Test CER | Val WER | Val CER |
|---|---|---|---|---|
| v1 | 0.404 | 0.226 | 0.3308 | 0.1820 |
| v2 | 0.3049 ↓ | 0.1119 ↓ | 0.2315 | 0.0776 |
Improvements:
This model is designed for extracting Arabic text from images, including:
from unsloth import FastVisionModel
from PIL import Image
import torch
# Load model
model, tokenizer = FastVisionModel.from_pretrained(
"AhmedZaky1/DIMI-Arabic-OCR-v2",
load_in_4bit=True,
device_map="auto"
)
FastVisionModel.for_inference(model)
# Load image
image = Image.open("arabic_document.jpg")
# Prepare prompt
instruction = "استخرج النص العربي والأرقام الموجودة في هذه الصورة بدقة عالية."
messages = [
{
"role": "user",
"content": [
{"type": "image", "image": image},
{"type": "text", "text": instruction},
],
}
]
# Apply chat template
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
# Tokenize
inputs = tokenizer(
text=[text],
images=[image],
padding=True,
return_tensors="pt",
truncation=False
).to("cuda")
# Generate
with torch.inference_mode():
outputs = model.generate(
**inputs,
max_new_tokens=2048,
do_sample=False
)
# Decode
generated_ids = [
out[len(inp):] for inp, out in zip(inputs.input_ids, outputs)
]
prediction = tokenizer.batch_decode(
generated_ids,
skip_special_tokens=True
)[0]
print(prediction)
Fine-tuned on 11,000 Arabic text images combining:
The dataset covers modern standard Arabic with and without diacritics.
If you use this model, please cite:
@misc{dimi-arabic-ocr-2025,
author = {Ahmed Zaky},
title = {DIMI-Arabic-OCR: Fine-tuned Qwen2.5-VL for Arabic Text Recognition},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/AhmedZaky1/DIMI-Arabic-OCR}}
}
Built with ❤️ by Ahmed Zaky
Advancing Arabic NLP through state-of-the-art embedding models
</div>