Update README.md
Browse files
README.md
CHANGED
|
@@ -1,35 +1,30 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
language:
|
| 4 |
-
- fa
|
| 5 |
pipeline_tag: image-to-text
|
| 6 |
widget:
|
| 7 |
-
- src: https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/papers/attention.png
|
| 8 |
-
|
| 9 |
---
|
| 10 |
|
| 11 |
-
---
|
| 12 |
# Persian-OCR
|
| 13 |
|
| 14 |
-
Persian-OCR is a deep learning model for **Optical Character Recognition (OCR)
|
| 15 |
-
|
| 16 |
-
trained with CTC loss to extract text from images.
|
| 17 |
|
| 18 |
## Files
|
| 19 |
|
| 20 |
-
- `pytorch_model.bin` : PyTorch model weights
|
| 21 |
-
- `vocab.json` : Character vocabulary
|
| 22 |
-
- `config.json` : Model configuration
|
| 23 |
|
| 24 |
## Installation
|
| 25 |
|
| 26 |
```bash
|
| 27 |
-
|
| 28 |
-
|
| 29 |
|
| 30 |
|
| 31 |
-
## Usage Example
|
| 32 |
-
|
| 33 |
|
| 34 |
import torch
|
| 35 |
import json
|
|
@@ -72,9 +67,13 @@ weights_path = hf_hub_download("farbodpya/Persian-OCR", "pytorch_model.bin")
|
|
| 72 |
model = CNN_Transformer_OCR(num_classes=len(idx_to_char)+1)
|
| 73 |
model.load_state_dict(torch.load(weights_path, map_location="cpu"))
|
| 74 |
model.eval()
|
|
|
|
| 75 |
# -----------------------------
|
| 76 |
-
#
|
| 77 |
# -----------------------------
|
| 78 |
-
img_path = "
|
| 79 |
text = ocr_page(img_path, model, idx_to_char, visualize=True)
|
| 80 |
-
print("\n=== Final OCR Page ===\n", text)
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
language:
|
| 4 |
+
- fa
|
| 5 |
pipeline_tag: image-to-text
|
| 6 |
widget:
|
| 7 |
+
- src: https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/papers/attention.png
|
| 8 |
+
example_title: "Persian OCR"
|
| 9 |
---
|
| 10 |
|
|
|
|
| 11 |
# Persian-OCR
|
| 12 |
|
| 13 |
+
**Persian-OCR** is a deep learning model for **Optical Character Recognition (OCR)**, designed specifically for Persian text.
|
| 14 |
+
The model uses a **CNN + Transformer architecture** trained with **CTC loss** to extract text from images.
|
|
|
|
| 15 |
|
| 16 |
## Files
|
| 17 |
|
| 18 |
+
- `pytorch_model.bin` : PyTorch model weights
|
| 19 |
+
- `vocab.json` : Character vocabulary
|
| 20 |
+
- `config.json` : Model configuration
|
| 21 |
|
| 22 |
## Installation
|
| 23 |
|
| 24 |
```bash
|
| 25 |
+
pip install torch torchvision huggingface_hub
|
|
|
|
| 26 |
|
| 27 |
|
|
|
|
|
|
|
| 28 |
|
| 29 |
import torch
|
| 30 |
import json
|
|
|
|
| 67 |
model = CNN_Transformer_OCR(num_classes=len(idx_to_char)+1)
|
| 68 |
model.load_state_dict(torch.load(weights_path, map_location="cpu"))
|
| 69 |
model.eval()
|
| 70 |
+
|
| 71 |
# -----------------------------
|
| 72 |
+
# 5️⃣ Example usage
|
| 73 |
# -----------------------------
|
| 74 |
+
img_path = "sample.png"
|
| 75 |
text = ocr_page(img_path, model, idx_to_char, visualize=True)
|
| 76 |
+
print("\n=== Final OCR Page ===\n", text)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|