|
--- |
|
tags: |
|
- trocr |
|
- ocr |
|
- text-recognition |
|
- pytorch |
|
- fine-tuned |
|
license: mit |
|
--- |
|
|
|
# 🏆 TrOCR Fine-Tuned Model (Handwritten Text Recognition) |
|
|
|
## 📌 **Model Overview** |
|
This is a fine-tuned **Microsoft TrOCR Large** model for **handwritten text recognition**. It has been trained on a dataset containing scanned handwritten documents. |
|
|
|
- **Base Model:** Microsoft TrOCR Large |
|
- **Fine-tuned On:** IAM Handwritten Dataset |
|
- **Use Case:** Extract text from scanned handwritten documents |
|
- **Framework:** PyTorch + Transformers (Hugging Face) |
|
- **Large File Support:** Uses `git-lfs` for model files |
|
|
|
--- |
|
|
|
## 🚀 **How to Use This Model** |
|
You can load and use the fine-tuned model with `transformers` in Python as follows: |
|
|
|
```python |
|
from transformers import TrOCRProcessor, VisionEncoderDecoderModel |
|
from PIL import Image |
|
|
|
# Load model and processor |
|
processor = TrOCRProcessor.from_pretrained("Gitesh2003/TrOCR") |
|
model = VisionEncoderDecoderModel.from_pretrained("Gitesh2003/TrOCR") |
|
|
|
# Load an image |
|
image = Image.open("handwritten_sample.jpg").convert("RGB") |
|
|
|
# Process and predict text |
|
pixel_values = processor(images=image, return_tensors="pt").pixel_values |
|
generated_ids = model.generate(pixel_values) |
|
extracted_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0] |
|
|
|
print("Extracted Text:", extracted_text) |
|
|
|
|