Downloads · 30 days
10
36% of all-time downloads
nik-hill/Hindi_Offline_Handwritten_OCR
Hindi_Offline_Handwritten_OCR is a machine learning model from nik-hill. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
This model is a Vision Encoder-Decoder-based OCR model for recognizing Hindi text from images. The encoder uses a Vision Transformer (ViT) architecture, and the decoder is based on a pre-trained Hindi RoBERTa model. T…
Downloads · 30 days
10
36% of all-time downloads
All-time downloads
28
Public
Parameters
168M
670 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors670 MB · 100%
From the Hugging Face model README
This model is a Vision Encoder-Decoder-based OCR model for recognizing Hindi text from images. The encoder uses a Vision Transformer (ViT) architecture, and the decoder is based on a pre-trained Hindi RoBERTa model. The model is capable of processing image inputs and generating corresponding text, specifically optimized for Hindi script.
Encoder: google/vit-base-patch16-224-in21k
Decoder: surajp/RoBERTa-hindi-guj-san
The model is designed to perform Optical Character Recognition (OCR) on images containing Hindi text. Some potential use cases include:
You can use this model with Hugging Face's transformers library to extract text from images. Below is a sample usage script:
from PIL import Image
from transformers import AutoFeatureExtractor, AutoTokenizer, TrOCRProcessor, VisionEncoderDecoderModel
# Load the model and processor
encoder_model = 'google/vit-base-patch16-224-in21k'
decoder_model = 'surajp/RoBERTa-hindi-guj-san'
trained_model_path = '.model/' # Path to the fine-tuned model
# Initialize the processor and model
feature_extractor = AutoFeatureExtractor.from_pretrained(encoder_model)
tokenizer = AutoTokenizer.from_pretrained(decoder_model)
processor = TrOCRProcessor(feature_extractor=feature_extractor, tokenizer=tokenizer)
model = VisionEncoderDecoderModel.from_pretrained(trained_model_path)
# Load and preprocess the image
image_path = 'path_to_your_image.jpg'
image = Image.open(image_path).convert('RGB')
# Generate text
pixel_values = processor(image, return_tensors='pt').pixel_values
generated_ids = model.generate(pixel_values)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print("Generated Text:", generated_text)
.jpg, .png, and .jpeg.# Input: Image containing Hindi text.
# Output: Extracted text from the image.
5e-5.The model was evaluated using standard OCR benchmarks with an emphasis on Hindi text recognition. The primary evaluation metric was character-level accuracy and Word Error Rate (WER).
This model, while useful for Hindi text extraction, should be applied with caution in contexts where incorrect text extraction could lead to harmful outcomes, such as legal or medical document analysis.
This model is distributed under the MIT license. Please check the Hugging Face repository for specific terms.
A live demo of the Hindi Offline Handwritten OCR can be found here:
Hindi Offline Handwritten OCR on Hugging Face Spaces