Qwen2.5-VL-3B-Instruct fine-tuned and merged for Tamil OCR.
LoRA adapter (pre-merge):
sair390/tamil-ocr-qwen25vl-lora
1from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
2from PIL import Image
3import torch
4
5model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
6 "sair390/tamil-ocr-qwen25vl",
7 torch_dtype=torch.bfloat16,
8 device_map="auto",
9)
10processor = AutoProcessor.from_pretrained("sair390/tamil-ocr-qwen25vl")
11
12image = Image.open("tamil_page.jpg")
13messages = [{
14 "role": "user",
15 "content": [
16 {"type": "image", "image": image},
17 {"type": "text", "text": "Read the Tamil text in this image."},
18 ],
19}]
20
21text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
22inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)
23
24with torch.no_grad():
25 output = model.generate(
26 **inputs,
27 max_new_tokens=512,
28 temperature=0, # deterministic — best for OCR
29 do_sample=False,
30 )
31
32result = processor.decode(output[0], skip_special_tokens=True)
33print(result)