Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- trocr
|
| 4 |
+
- ocr
|
| 5 |
+
- text-recognition
|
| 6 |
+
- pytorch
|
| 7 |
+
- fine-tuned
|
| 8 |
+
license: mit
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
# 🏆 TrOCR Fine-Tuned Model (Handwritten Text Recognition)
|
| 12 |
+
|
| 13 |
+
## 📌 **Model Overview**
|
| 14 |
+
This is a fine-tuned **Microsoft TrOCR Large** model for **handwritten text recognition**. It has been trained on a dataset containing scanned handwritten documents.
|
| 15 |
+
|
| 16 |
+
- **Base Model:** Microsoft TrOCR Large
|
| 17 |
+
- **Fine-tuned On:** IAM Handwritten Dataset
|
| 18 |
+
- **Use Case:** Extract text from scanned handwritten documents
|
| 19 |
+
- **Framework:** PyTorch + Transformers (Hugging Face)
|
| 20 |
+
- **Large File Support:** Uses `git-lfs` for model files
|
| 21 |
+
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
## 🚀 **How to Use This Model**
|
| 25 |
+
You can load and use the fine-tuned model with `transformers` in Python as follows:
|
| 26 |
+
|
| 27 |
+
```python
|
| 28 |
+
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
|
| 29 |
+
from PIL import Image
|
| 30 |
+
|
| 31 |
+
# Load model and processor
|
| 32 |
+
processor = TrOCRProcessor.from_pretrained("Gitesh2003/TrOCR")
|
| 33 |
+
model = VisionEncoderDecoderModel.from_pretrained("Gitesh2003/TrOCR")
|
| 34 |
+
|
| 35 |
+
# Load an image
|
| 36 |
+
image = Image.open("handwritten_sample.jpg").convert("RGB")
|
| 37 |
+
|
| 38 |
+
# Process and predict text
|
| 39 |
+
pixel_values = processor(images=image, return_tensors="pt").pixel_values
|
| 40 |
+
generated_ids = model.generate(pixel_values)
|
| 41 |
+
extracted_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 42 |
+
|
| 43 |
+
print("Extracted Text:", extracted_text)
|