Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,43 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- ocr
|
| 5 |
+
- handwritten-text
|
| 6 |
+
- trocr
|
| 7 |
+
- pytorch
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# Model Name: TrOCR Fine-Tuned on Custom Dataset
|
| 11 |
+
|
| 12 |
+
This model is a fine-tuned version of Microsoft's `TrOCR` on a custom dataset for handwritten text extraction from scanned documents.
|
| 13 |
+
|
| 14 |
+
## 🧠 Model Architecture
|
| 15 |
+
- **Base model**: Microsoft TrOCR (base)
|
| 16 |
+
- **Used with**: CRAFT for text detection
|
| 17 |
+
- **Fine-tuned with**: OCR-specific dataset
|
| 18 |
+
|
| 19 |
+
## 📁 Files in this repository:
|
| 20 |
+
- `pytorch_model.bin`: Model weights (2.1 GB)
|
| 21 |
+
- `config.json`, `tokenizer_config.json`, etc.
|
| 22 |
+
- Training and evaluation scripts (optional)
|
| 23 |
+
|
| 24 |
+
## 🚀 How to Use
|
| 25 |
+
|
| 26 |
+
```python
|
| 27 |
+
from transformers import VisionEncoderDecoderModel, TrOCRProcessor
|
| 28 |
+
from PIL import Image
|
| 29 |
+
import torch
|
| 30 |
+
|
| 31 |
+
# Load processor and model
|
| 32 |
+
processor = TrOCRProcessor.from_pretrained("Gitesh2003/MESA_TrOCR")
|
| 33 |
+
model = VisionEncoderDecoderModel.from_pretrained("Gitesh2003/MESA_TrOCR")
|
| 34 |
+
|
| 35 |
+
# Load image
|
| 36 |
+
image = Image.open("sample_image.jpg").convert("RGB")
|
| 37 |
+
|
| 38 |
+
# OCR
|
| 39 |
+
pixel_values = processor(images=image, return_tensors="pt").pixel_values
|
| 40 |
+
generated_ids = model.generate(pixel_values)
|
| 41 |
+
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 42 |
+
|
| 43 |
+
print(generated_text)
|