tawkeed-ocr
179
license:apache-2.0
by
tawkeed-sa
Other
OTHER
2B params
New
179 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
5GB+ RAM
Mobile
Laptop
Server
Quick Summary
AI model with specialized capabilities.
Device Compatibility
Mobile
4-6GB RAM
Laptop
16GB RAM
Server
GPU
Minimum Recommended
2GB+ RAM
Code Examples
Usagepythontransformers
from transformers import AutoProcessor, AutoModelForVision2Seq
from PIL import Image
model_id = "tawkeed-sa/tawkeed-ocr"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForVision2Seq.from_pretrained(
model_id,
device_map="auto",
torch_dtype="auto",
)
# Load an Arabic document image
image = Image.open("arabic_document.png")
# Extract text
messages = [
{
"role": "user",
"content": [
{"type": "image"},
{"type": "text", "text": "استخرج جميع النصوص العربية من هذه الصورة"},
],
}
]
inputs = processor.apply_chat_template(messages, images=[image], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=2048)
result = processor.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
print(result)Batch Processingpythontransformers
from pathlib import Path
from PIL import Image
from transformers import AutoProcessor, AutoModelForVision2Seq
model_id = "tawkeed-sa/tawkeed-ocr"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForVision2Seq.from_pretrained(model_id, device_map="auto", torch_dtype="auto")
# Process multiple document pages
for img_path in sorted(Path("scanned_pages/").glob("*.png")):
image = Image.open(img_path)
messages = [
{
"role": "user",
"content": [
{"type": "image"},
{"type": "text", "text": "Extract all text from this document page."},
],
}
]
inputs = processor.apply_chat_template(messages, images=[image], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=2048)
text = processor.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True)
print(f"--- {img_path.name} ---")
print(text)Deploy This Model
Production-ready deployment in minutes
Together.ai
Instant API access to this model
Production-ready inference API. Start free, scale to millions.
Try Free APIReplicate
One-click model deployment
Run models in the cloud with simple API. No DevOps required.
Deploy NowDisclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.