Update README.md
Browse files
README.md
CHANGED
@@ -19,4 +19,58 @@ features:
|
|
19 |
dtype: string
|
20 |
tags:
|
21 |
- dataset
|
22 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
dtype: string
|
20 |
tags:
|
21 |
- dataset
|
22 |
+
---
|
23 |
+
|
24 |
+
### Dataset Description
|
25 |
+
|
26 |
+
This dataset is designed for training and evaluating Optical Character Recognition (OCR) models
|
27 |
+
for Arabic text. It is an extension of an open-source dataset and includes text rendered in multiple Arabic fonts (Amiri, Sakkal Majalla, Arial, Calibri and Scheherazade New).
|
28 |
+
The dataset simulates real-world book layouts to enhance OCR accuracy.
|
29 |
+
|
30 |
+
### Dataset Structure
|
31 |
+
The dataset is divided into five splits based on font name (Sakkal_Majalla, Amiri, Arial, Calibri, and Scheherazade_New).
|
32 |
+
Each split contains data specific to a single font. Within each split, the following attributes are present:
|
33 |
+
- **image_name**: Unique identifier for each image.
|
34 |
+
- **chunk**: The text content associated with the image.
|
35 |
+
|
36 |
+
- **font_name**: The font used in text rendering.
|
37 |
+
|
38 |
+
- **image_base64**: Base64-encoded image representation.
|
39 |
+
|
40 |
+
### How to Use
|
41 |
+
|
42 |
+
```python
|
43 |
+
from datasets import load_dataset
|
44 |
+
import base64
|
45 |
+
from io import BytesIO
|
46 |
+
from PIL import Image
|
47 |
+
# Load dataset with streaming enabled
|
48 |
+
ds = load_dataset("xya22er/text_to_image", streaming=True)
|
49 |
+
print(ds)
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
# Load the dataset
|
55 |
+
|
56 |
+
# Iterate over a specific font dataset (e.g., Amiri)
|
57 |
+
for sample in ds["Amiri"]:
|
58 |
+
image_name = sample["image_name"]
|
59 |
+
chunk = sample["chunk"] # Arabic text transcription
|
60 |
+
font_name = sample["font_name"]
|
61 |
+
|
62 |
+
# Decode Base64 image
|
63 |
+
image_data = base64.b64decode(sample["image_base64"])
|
64 |
+
image = Image.open(BytesIO(image_data))
|
65 |
+
|
66 |
+
# Show the image (optional)
|
67 |
+
image.show()
|
68 |
+
|
69 |
+
# Print the details
|
70 |
+
print(f"Image Name: {image_name}")
|
71 |
+
print(f"Font Name: {font_name}")
|
72 |
+
print(f"Text Chunk: {chunk}")
|
73 |
+
|
74 |
+
# Break after one sample for testing
|
75 |
+
break
|
76 |
+
```
|