Update README.md
Browse files
README.md
CHANGED
|
@@ -22,6 +22,63 @@ CrossLing-OCR-Mini is optimized for **low-resource and structurally complex lang
|
|
| 22 |
|
| 23 |
Experimental results show that CrossLing-OCR-Mini **outperforms or matches mainstream OCR systems** on multiple low-resource languages.
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
---
|
| 26 |
|
| 27 |
## 🧪 Performance Notes & Limitations
|
|
|
|
| 22 |
|
| 23 |
Experimental results show that CrossLing-OCR-Mini **outperforms or matches mainstream OCR systems** on multiple low-resource languages.
|
| 24 |
|
| 25 |
+
|
| 26 |
+
## 🚀 Usage / Inference
|
| 27 |
+
|
| 28 |
+
You can easily perform inference with CrossLing-OCR-Mini using the 🤗 Transformers library.
|
| 29 |
+
The following example demonstrates a simple OCR inference pipeline on a single image.
|
| 30 |
+
|
| 31 |
+
🔧 Requirements
|
| 32 |
+
|
| 33 |
+
Python ≥ 3.8
|
| 34 |
+
|
| 35 |
+
transformers (latest recommended)
|
| 36 |
+
|
| 37 |
+
CUDA-enabled GPU (recommended for better performance)
|
| 38 |
+
|
| 39 |
+
```
|
| 40 |
+
pip install -U transformers accelerate
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
## 🧪 Simple OCR Inference Example
|
| 44 |
+
```
|
| 45 |
+
from transformers import AutoModel, AutoTokenizer
|
| 46 |
+
import os
|
| 47 |
+
|
| 48 |
+
# Path or Hugging Face model id
|
| 49 |
+
model_id = "checkpoint-80000-merged"
|
| 50 |
+
|
| 51 |
+
# Load tokenizer and model
|
| 52 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 53 |
+
model_id,
|
| 54 |
+
trust_remote_code=True
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
model = AutoModel.from_pretrained(
|
| 58 |
+
model_id,
|
| 59 |
+
trust_remote_code=True,
|
| 60 |
+
low_cpu_mem_usage=True,
|
| 61 |
+
device_map="cuda",
|
| 62 |
+
use_safetensors=True,
|
| 63 |
+
pad_token_id=tokenizer.eos_token_id
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
model = model.eval().cuda()
|
| 67 |
+
|
| 68 |
+
# Input image for OCR
|
| 69 |
+
image_file = "test.png"
|
| 70 |
+
|
| 71 |
+
# Perform plain text OCR
|
| 72 |
+
result = model.chat(
|
| 73 |
+
tokenizer,
|
| 74 |
+
image_file,
|
| 75 |
+
ocr_type="ocr"
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
print("Predicted OCR result:\n")
|
| 79 |
+
print(result)
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
---
|
| 83 |
|
| 84 |
## 🧪 Performance Notes & Limitations
|