DevGen TrOCR Devanagari LoRA Adapter
This repository contains the DevGen LoRA adapter for Devanagari OCR. It is intended to be loaded on top of paudelanil/trocr-devanagari-2 with PEFT.
Model Details
- Developed by: Sameer Wagle / DevGen
- Base model:
paudelanil/trocr-devanagari-2
- Adapter type: LoRA
- Task: image-to-text OCR for Devanagari word and short-line images
- Library: PEFT + Transformers
Intended Use
Use this adapter for recognizing Devanagari text from cropped handwritten or printed word images. The DevGen runtime also supports light preprocessing such as foreground cropping and square padding for uploaded document-like images.
This model is not a general document understanding system. It does not perform page layout analysis, table extraction, translation, or language correction.
Loading
1from peft import PeftModel
2from transformers import AutoTokenizer, TrOCRProcessor, ViTImageProcessor, VisionEncoderDecoderModel
3
4base_model_id = "paudelanil/trocr-devanagari-2"
5adapter_id = "waglesameer5/devgen-trocr-devanagari-lora"
6
7image_processor = ViTImageProcessor.from_pretrained(adapter_id)
8tokenizer = AutoTokenizer.from_pretrained(base_model_id)
9processor = TrOCRProcessor(image_processor=image_processor, tokenizer=tokenizer)
10
11base_model = VisionEncoderDecoderModel.from_pretrained(base_model_id)
12model = PeftModel.from_pretrained(base_model, adapter_id)
Demo
A hosted Gradio demo is available as a Hugging Face Space:
waglesameer5/devgen-devanagari-ocr
Limitations
The adapter is most reliable on clear Devanagari word or short-line crops. Accuracy can degrade on very noisy images, multi-column documents, severe blur, extreme rotation, or text outside the training distribution.
Training And Evaluation
The adapter was trained in the DevGen OCR workspace using a LoRA fine-tuning workflow for TrOCR. The local project includes reproducible evaluation scripts for corpus character error rate, word error rate, exact match, and preprocessing ablations.
Framework Versions
- PEFT 0.19.1
- Transformers
- PyTorch