riotu-lab commited on
Commit
d90bbf7
·
verified ·
1 Parent(s): 85525d7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +118 -19
README.md CHANGED
@@ -34,35 +34,104 @@ size_categories:
34
  - n>1T
35
  ---
36
 
37
- ### Dataset Description
38
 
39
- This dataset is designed for training and evaluating Optical Character Recognition (OCR) models
40
- 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).
41
- The dataset simulates real-world book layouts to enhance OCR accuracy.
42
 
43
- ### Dataset Structure
44
- The dataset is divided into five splits based on font name (Sakkal_Majalla, Amiri, Arial, Calibri, and Scheherazade_New).
45
- Each split contains data specific to a single font. Within each split, the following attributes are present:
46
- - **image_name**: Unique identifier for each image.
47
- - **chunk**: The text content associated with the image.
48
 
49
- - **font_name**: The font used in text rendering.
50
 
51
- - **image_base64**: Base64-encoded image representation.
52
 
53
- ### How to Use
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  ```python
56
  from datasets import load_dataset
57
  import base64
58
  from io import BytesIO
59
  from PIL import Image
 
 
60
  # Load dataset with streaming enabled
61
- ds = load_dataset("riotu-lab/text2image", streaming=True)
62
  print(ds)
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 +142,12 @@ for sample in ds["Amiri"]:
73
  image_data = base64.b64decode(sample["image_base64"])
74
  image = Image.open(BytesIO(image_data))
75
 
76
- # Show the image (optional)
77
- image.show()
 
 
 
 
78
 
79
  # Print the details
80
  print(f"Image Name: {image_name}")
@@ -85,5 +158,31 @@ for sample in ds["Amiri"]:
85
  break
86
  ```
87
 
88
- # OCR Dataset Generation Pipeline
89
- To create your own dataset, you can use the following repository: [text2image](https://github.com/riotu-lab/text2image).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  - n>1T
35
  ---
36
 
37
+ # SAND: Large-Scale Synthetic Arabic OCR Dataset
38
 
39
+ [![Hugging Face Datasets](https://img.shields.io/badge/🤗%20Hugging%20Face-Datasets-yellow)](https://huggingface.co/datasets/riotu-lab/SAND)
40
+ [![GitHub](https://img.shields.io/badge/GitHub-Repository-blue)](https://github.com/riotu-lab/text2image)
 
41
 
42
+ ## Overview
 
 
 
 
43
 
44
+ **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.
45
 
46
+ ## Key Features
47
 
48
+ - **Massive Scale**: 743,000 document images containing 662.15 million words
49
+ - **Typographic Diversity**: Five distinct Arabic fonts (Amiri, Sakkal Majalla, Arial, Calibri, and Scheherazade New)
50
+ - **Structured Formatting**: Designed to mimic real-world book layouts with consistent typography
51
+ - **Clean Data**: Synthetically generated with no scanning artifacts, blur, or distortions
52
+ - **Content Diversity**: Text spans multiple domains including culture, literature, Shariah, social topics, and more
53
+
54
+ ## Dataset Structure
55
+
56
+ The dataset is divided into five splits based on font name:
57
+
58
+ - **Amiri**: ~148,541 document images
59
+ - **Sakkal Majalla**: ~148,541 document images
60
+ - **Arial**: ~148,541 document images
61
+ - **Calibri**: ~148,541 document images
62
+ - **Scheherazade New**: ~148,541 document images
63
+
64
+ 📋 Sample Images
65
+ <div align="center">
66
+ <table>
67
+ <tr>
68
+ <td><img src="https://cdn-uploads.huggingface.co/production/uploads/64e8eb21233101ed99b204c8/gwF9jkkkpzRSzrP9GCE_l.png" width="300" alt="Sample 1 - Amiri Font"/></td>
69
+ <td><img src="https://cdn-uploads.huggingface.co/production/uploads/64e8eb21233101ed99b204c8/dsqWoCh5x31eGq-u-PqPS.png" width="300" alt="Sample 2 - Arial Font"/></td>
70
+ </tr>
71
+ <tr>
72
+ <td><img src="https://cdn-uploads.huggingface.co/production/uploads/64e8eb21233101ed99b204c8/2XK9Ey6k6HSDXKXCxmVRG.png" width="300" alt="Sample 3 - Calibri Font"/></td>
73
+ <td><img src="https://cdn-uploads.huggingface.co/production/uploads/64e8eb21233101ed99b204c8/CxKITKvc3EnDIuqnNy_bV.png" width="300" alt="Sample 4 - Scheherazade Font"/></td>
74
+ </tr>
75
+ </table>
76
+ </div>
77
+
78
+ Each split contains data specific to a single font with the following attributes:
79
+
80
+ - `image_name`: Unique identifier for each image
81
+ - `chunk`: The text content associated with the image
82
+ - `font_name`: The font used in text rendering
83
+ - `image_base64`: Base64-encoded image representation
84
+
85
+ ## Content Distribution
86
+
87
+ | Category | Number of Articles |
88
+ |----------|-------------------|
89
+ | Culture | 13,253 |
90
+ | Fatawa & Counsels | 8,096 |
91
+ | Literature & Language | 11,581 |
92
+ | Bibliography | 26,393 |
93
+ | Publications & Competitions | 1,123 |
94
+ | Shariah | 46,665 |
95
+ | Social | 8,827 |
96
+ | Translations | 443 |
97
+ | Muslim's News | 16,725 |
98
+ | **Total Articles** | **133,105** |
99
+
100
+ ## Font Specifications
101
+
102
+ | Font | Words Per Page | Font Size |
103
+ |------|----------------|-----------|
104
+ | Sakkal Majalla | 50–300 | 14 pt |
105
+ | Arial | 50–500 | 12 pt |
106
+ | Calibri | 50–500 | 12 pt |
107
+ | Amiri | 50–300 | 12 pt |
108
+ | Scheherazade | 50–250 | 12 pt |
109
+
110
+ ## Page Layout
111
+
112
+ | Specification | Measurement |
113
+ |---------------|-------------|
114
+ | Left Margin | 0.9 inches |
115
+ | Right Margin | 0.9 inches |
116
+ | Top Margin | 1.0 inch |
117
+ | Bottom Margin | 1.0 inch |
118
+ | Gutter Margin | 0.2 inches |
119
+ | Page Width | 8.27 inches (A4) |
120
+ | Page Height | 11.69 inches (A4) |
121
+
122
+ ## Usage Example
123
 
124
  ```python
125
  from datasets import load_dataset
126
  import base64
127
  from io import BytesIO
128
  from PIL import Image
129
+ import matplotlib.pyplot as plt
130
+
131
  # Load dataset with streaming enabled
132
+ ds = load_dataset("riotu-lab/SAND", streaming=True)
133
  print(ds)
134
 
 
 
135
  # Iterate over a specific font dataset (e.g., Amiri)
136
  for sample in ds["Amiri"]:
137
  image_name = sample["image_name"]
 
142
  image_data = base64.b64decode(sample["image_base64"])
143
  image = Image.open(BytesIO(image_data))
144
 
145
+ # Display the image
146
+ plt.figure(figsize=(10, 10))
147
+ plt.imshow(image)
148
+ plt.axis('off')
149
+ plt.title(f"Font: {font_name}")
150
+ plt.show()
151
 
152
  # Print the details
153
  print(f"Image Name: {image_name}")
 
158
  break
159
  ```
160
 
161
+
162
+ ## Applications
163
+
164
+ SAND is designed to support various Arabic text recognition tasks:
165
+
166
+ - Training and evaluating OCR models for Arabic text
167
+ - Developing vision-language models for document understanding
168
+ - Fine-tuning existing OCR models for better Arabic script recognition
169
+ - Benchmarking OCR performance across different fonts and layouts
170
+ - Research in Arabic natural language processing and computer vision
171
+
172
+ ## Citation
173
+
174
+ If you use SAND in your research, please cite:
175
+
176
+ ```bibtex
177
+ @misc{sand2025,
178
+ title={SAND: A Large-Scale Synthetic Arabic OCR Corpus for Vision-Language Models},
179
+ author={RIOTU Lab},
180
+ year={2025},
181
+ howpublished={\url{https://huggingface.co/datasets/riotu-lab/SAND}}
182
+ }
183
+ ```
184
+
185
+ ## Acknowledgments
186
+
187
+ The authors thank Prince Sultan University for their support in developing this dataset.
188
+