Downloads · 30 days
130
6% of all-time downloads
aayushpuri01/TrOCR-Devanagari
TrOCR-Devanagari is a machine learning model from aayushpuri01. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This model is a Devanagari Optical Character Recognition (OCR) model based on VisionEncoderDecoder architecture, fine-tuned on Nepali/Devanagari script. The model uses the TrOCRProcessor from Hugging Face to process a…
Downloads · 30 days
130
6% of all-time downloads
All-time downloads
2K
Public
Parameters
184M
736 MB on disk
Likes
3
Public
Click a slice to open those files.
.safetensors736 MB · 100%
From the Hugging Face model README
This model is a Devanagari Optical Character Recognition (OCR) model based on VisionEncoderDecoder architecture, fine-tuned on Nepali/Devanagari script. The model uses the TrOCRProcessor from Hugging Face to process and generate text from images.
Processor: TrOCRProcessor combining a Vision Transformer (ViT) feature extractor and a tokenizer.
You can use this model in Python with the following steps:
from transformers import VisionEncoderDecoderModel, TrOCRProcessor, AutoTokenizer
from PIL import Image
import torch
# Load the model and processor
tokenizer = AutoTokenizer.from_pretrained("aayushpuri01/TrOCR-Devanagari")
model = VisionEncoderDecoderModel.from_pretrained("aayushpuri01/TrOCR-Devanagari")
processor = TrOCRProcessor.from_pretrained("aayushpuri01/TrOCR-Devanagari")
# Load image
image = Image.open("path_to_image").convert("RGB")
# Preprocess image
pixel_values = processor(image, return_tensors="pt").pixel_values
# Generate text
generated_ids = model.generate(pixel_values)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(generated_text)