Update README.md
Browse files
README.md
CHANGED
@@ -29,40 +29,122 @@ features:
|
|
29 |
dtype: string
|
30 |
tags:
|
31 |
- dataset
|
|
|
|
|
32 |
---
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
- **
|
47 |
-
|
48 |
-
- **
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
```python
|
53 |
from datasets import load_dataset
|
54 |
import base64
|
55 |
from io import BytesIO
|
56 |
from PIL import Image
|
|
|
|
|
57 |
# Load dataset with streaming enabled
|
58 |
-
ds = load_dataset("riotu-lab/
|
59 |
print(ds)
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
# Load the dataset
|
65 |
-
|
66 |
# Iterate over a specific font dataset (e.g., Amiri)
|
67 |
for sample in ds["Amiri"]:
|
68 |
image_name = sample["image_name"]
|
@@ -73,8 +155,12 @@ for sample in ds["Amiri"]:
|
|
73 |
image_data = base64.b64decode(sample["image_base64"])
|
74 |
image = Image.open(BytesIO(image_data))
|
75 |
|
76 |
-
#
|
77 |
-
|
|
|
|
|
|
|
|
|
78 |
|
79 |
# Print the details
|
80 |
print(f"Image Name: {image_name}")
|
@@ -85,6 +171,60 @@ for sample in ds["Amiri"]:
|
|
85 |
break
|
86 |
```
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
-
|
90 |
-
To create your own dataset, you can use the following repository: [text2image](https://github.com/riotu-lab/text2image).
|
|
|
29 |
dtype: string
|
30 |
tags:
|
31 |
- dataset
|
32 |
+
license: apache-2.0
|
33 |
+
pretty_name: SAND
|
34 |
---
|
35 |
|
36 |
+
# SAND: A Large-Scale Synthetic Arabic OCR Dataset
|
37 |
+
|
38 |
+
[](https://huggingface.co/datasets/riotu-lab/SAND)
|
39 |
+
[](https://github.com/riotu-lab/text2image)
|
40 |
+
|
41 |
+
## Overview
|
42 |
+
|
43 |
+
**SAND** (Synthetic Arabic OCR Dataset) is a large-scale, synthetically generated dataset designed for training and evaluating Optical Character Recognition (OCR) models for Arabic text. This dataset addresses the critical need for comprehensive Arabic text recognition resources by providing controlled, diverse, and scalable training data that simulates real-world book layouts.
|
44 |
+
|
45 |
+
## Key Features
|
46 |
+
|
47 |
+
- **Massive Scale**: 843,622 document images containing approximately 690 million words
|
48 |
+
- **Extensive Typographic Diversity**: Ten distinct Arabic fonts covering a wide range of styles
|
49 |
+
- **Structured Formatting**: Designed to mimic real-world book layouts with consistent typography
|
50 |
+
- **Clean Data**: Synthetically generated with no scanning artifacts, blur, or distortions
|
51 |
+
- **Content Diversity**: Text spans multiple domains including culture, literature, Shariah, social topics, and more
|
52 |
+
|
53 |
+
## Dataset Structure
|
54 |
+
|
55 |
+
The dataset is divided into ten splits based on font name:
|
56 |
+
|
57 |
+
- **Amiri**: Classical Naskh typeface inspired by early 20th century typography
|
58 |
+
- **Sakkal Majalla**: Widely used font in contemporary Arabic publishing
|
59 |
+
- **Arial**: Modern sans-serif font common in digital publications
|
60 |
+
- **Calibri**: Microsoft's default font representing contemporary digital typography
|
61 |
+
- **Scheherazade New**: Traditional-style font based on classical manuscript styles
|
62 |
+
- **Jozoor Font**: Decorative Arabic font with more stylized character forms
|
63 |
+
- **Lateef**: Extended Arabic script font designed for readability at small sizes
|
64 |
+
- **Noto Naskh Arabic UI**: Part of Google's Noto family, designed for user interfaces
|
65 |
+
- **Thabit**: Monospaced Arabic font for technical documentation
|
66 |
+
- **Al Jazeera Arabic Regular**: Based on the typography used by Al Jazeera media
|
67 |
+
|
68 |
+
📋 Sample Images
|
69 |
+
<div align="center">
|
70 |
+
<table>
|
71 |
+
<tr>
|
72 |
+
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/64e8eb21233101ed99b204c8/gwF9jkkkpzRSzrP9GCE_l.png" width="300" alt="Sample 1 - Amiri Font"/></td>
|
73 |
+
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/64e8eb21233101ed99b204c8/dsqWoCh5x31eGq-u-PqPS.png" width="300" alt="Sample 2 - Arial Font"/></td>
|
74 |
+
</tr>
|
75 |
+
<tr>
|
76 |
+
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/64e8eb21233101ed99b204c8/2XK9Ey6k6HSDXKXCxmVRG.png" width="300" alt="Sample 3 - Calibri Font"/></td>
|
77 |
+
<td><img src="https://cdn-uploads.huggingface.co/production/uploads/64e8eb21233101ed99b204c8/CxKITKvc3EnDIuqnNy_bV.png" width="300" alt="Sample 4 - Scheherazade Font"/></td>
|
78 |
+
</tr>
|
79 |
+
</table>
|
80 |
+
</div>
|
81 |
+
|
82 |
+
Each split contains data specific to a single font with the following attributes:
|
83 |
+
|
84 |
+
- `image_name`: Unique identifier for each image
|
85 |
+
- `chunk`: The text content associated with the image
|
86 |
+
- `font_name`: The font used in text rendering
|
87 |
+
- `image_base64`: Base64-encoded image representation
|
88 |
+
|
89 |
+
## Content Distribution
|
90 |
+
|
91 |
+
| Category | Number of Articles |
|
92 |
+
|----------|-------------------|
|
93 |
+
| Culture | 13,253 |
|
94 |
+
| Fatawa & Counsels | 8,096 |
|
95 |
+
| Literature & Language | 11,581 |
|
96 |
+
| Bibliography | 26,393 |
|
97 |
+
| Publications & Competitions | 1,123 |
|
98 |
+
| Shariah | 46,665 |
|
99 |
+
| Social | 8,827 |
|
100 |
+
| Translations | 443 |
|
101 |
+
| Muslim's News | 16,725 |
|
102 |
+
| **Total Articles** | **133,105** |
|
103 |
+
|
104 |
+
## Font Specifications
|
105 |
+
|
106 |
+
| Font | Words Per Page | Font Size | Characteristics |
|
107 |
+
|------|----------------|-----------|-----------------|
|
108 |
+
| Sakkal Majalla | 50–300 | 14 pt | Contemporary publishing style |
|
109 |
+
| Arial | 50–500 | 12 pt | Modern sans-serif |
|
110 |
+
| Calibri | 50–500 | 12 pt | Contemporary digital document |
|
111 |
+
| Amiri | 50–300 | 12 pt | Classical Naskh typeface |
|
112 |
+
| Scheherazade New | 50–250 | 12 pt | Traditional manuscript style |
|
113 |
+
| Noto Naskh Arabic UI | 50–400 | 12 pt | Clear UI rendering |
|
114 |
+
| Lateef | 50–350 | 14 pt | Optimized for small sizes |
|
115 |
+
| Al-Jazeera-Arabic | 50–250 | 12 pt | Media/journalistic style |
|
116 |
+
| Thabit | 50–240 | 12 pt | Monospaced technical font |
|
117 |
+
| Jozoor Font | 50–200 | 12 pt | Decorative with stylization |
|
118 |
+
|
119 |
+
## Page Layout
|
120 |
+
|
121 |
+
| Specification | Measurement |
|
122 |
+
|---------------|-------------|
|
123 |
+
| Page Size | A4 (8.27 × 11.69 in) |
|
124 |
+
| Left Margin | 0.9 in |
|
125 |
+
| Right Margin | 0.9 in |
|
126 |
+
| Top Margin | 1.0 in |
|
127 |
+
| Bottom Margin | 1.0 in |
|
128 |
+
| Gutter Margin | 0.2 in |
|
129 |
+
| Resolution | 300 DPI |
|
130 |
+
| Color Mode | Grayscale |
|
131 |
+
| Page Direction | Right-to-Left |
|
132 |
+
| Text Alignment | Right |
|
133 |
+
| Line Spacing | 1.15 |
|
134 |
+
|
135 |
+
## Usage Example
|
136 |
|
137 |
```python
|
138 |
from datasets import load_dataset
|
139 |
import base64
|
140 |
from io import BytesIO
|
141 |
from PIL import Image
|
142 |
+
import matplotlib.pyplot as plt
|
143 |
+
|
144 |
# Load dataset with streaming enabled
|
145 |
+
ds = load_dataset("riotu-lab/SAND-Extended", streaming=True)
|
146 |
print(ds)
|
147 |
|
|
|
|
|
|
|
|
|
|
|
148 |
# Iterate over a specific font dataset (e.g., Amiri)
|
149 |
for sample in ds["Amiri"]:
|
150 |
image_name = sample["image_name"]
|
|
|
155 |
image_data = base64.b64decode(sample["image_base64"])
|
156 |
image = Image.open(BytesIO(image_data))
|
157 |
|
158 |
+
# Display the image
|
159 |
+
plt.figure(figsize=(10, 10))
|
160 |
+
plt.imshow(image)
|
161 |
+
plt.axis('off')
|
162 |
+
plt.title(f"Font: {font_name}")
|
163 |
+
plt.show()
|
164 |
|
165 |
# Print the details
|
166 |
print(f"Image Name: {image_name}")
|
|
|
171 |
break
|
172 |
```
|
173 |
|
174 |
+
## Working with Multiple Fonts
|
175 |
+
|
176 |
+
To train or evaluate models across different font styles:
|
177 |
+
|
178 |
+
```python
|
179 |
+
from datasets import load_dataset
|
180 |
+
import random
|
181 |
+
|
182 |
+
# Load the dataset
|
183 |
+
ds = load_dataset("riotu-lab/SAND")
|
184 |
+
|
185 |
+
# Select a balanced sample from multiple fonts
|
186 |
+
fonts_to_use = ["Amiri", "Arial", "Scheherazade_New", "Thabit", "Noto_Naskh_Arabic_UI"]
|
187 |
+
samples_per_font = 1000
|
188 |
+
combined_samples = []
|
189 |
+
|
190 |
+
for font in fonts_to_use:
|
191 |
+
# Get random samples from this font
|
192 |
+
font_samples = ds[font].shuffle(seed=42).select(range(samples_per_font))
|
193 |
+
combined_samples.extend([(sample, font) for sample in font_samples])
|
194 |
+
|
195 |
+
# Shuffle the combined samples
|
196 |
+
random.shuffle(combined_samples)
|
197 |
+
|
198 |
+
# Now you can use these samples for training or evaluation
|
199 |
+
for sample, font in combined_samples[:5]: # Just show first 5 as example
|
200 |
+
print(f"Font: {font}, Image: {sample['image_name']}")
|
201 |
+
```
|
202 |
+
|
203 |
+
|
204 |
+
## Applications
|
205 |
+
|
206 |
+
SAND is designed to support various Arabic text recognition tasks:
|
207 |
+
|
208 |
+
- Training and evaluating OCR models for Arabic text
|
209 |
+
- Developing vision-language models for document understanding
|
210 |
+
- Fine-tuning existing OCR models for better Arabic script recognition
|
211 |
+
- Benchmarking OCR performance across different fonts and layouts
|
212 |
+
- Research in Arabic natural language processing and computer vision
|
213 |
+
- Developing font-adaptive OCR systems that generalize across typographic styles
|
214 |
+
|
215 |
+
## Citation
|
216 |
+
|
217 |
+
If you use SAND in your research, please cite:
|
218 |
+
|
219 |
+
```bibtex
|
220 |
+
@misc{sand2025,
|
221 |
+
title={SAND: A Large-Scale Synthetic Arabic OCR Dataset for Vision-Language Models},
|
222 |
+
author={RIOTU Lab},
|
223 |
+
year={2025},
|
224 |
+
howpublished={\url{https://huggingface.co/datasets/riotu-lab/SAND}}
|
225 |
+
}
|
226 |
+
```
|
227 |
+
|
228 |
+
## Acknowledgments
|
229 |
|
230 |
+
The authors thank Prince Sultan University for their support in developing this dataset.
|
|