Instructions to use syubraj/TrOCR_Nepali with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use syubraj/TrOCR_Nepali with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("image-to-text", model="syubraj/TrOCR_Nepali")# Load model directly from transformers import AutoTokenizer, AutoModelForImageTextToText tokenizer = AutoTokenizer.from_pretrained("syubraj/TrOCR_Nepali") model = AutoModelForImageTextToText.from_pretrained("syubraj/TrOCR_Nepali") - Notebooks
- Google Colab
- Kaggle
Devanagari OCR with TrOCR
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.
Model Details
- Model:
syubraj/TrOCR_Nepali - Processor: TrOCRProcessor combining a Vision Transformer (ViT) feature extractor and a tokenizer.
How to Use
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("syubraj/TrOCR_Nepali")
model = VisionEncoderDecoderModel.from_pretrained("syubraj/TrOCR_Nepali")
processor = TrOCRProcessor.from_pretrained("syubraj/TrOCR_Nepali")
# 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)
- Downloads last month
- 119