alakxender commited on
Commit
c1fef2e
Β·
verified Β·
1 Parent(s): 537cca3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +151 -0
README.md CHANGED
@@ -64,3 +64,154 @@ pretty_name: dv_page_annotation
64
  size_categories:
65
  - 10K<n<100K
66
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  size_categories:
65
  - 10K<n<100K
66
  ---
67
+
68
+ # πŸ“¦ Dhivehi Synthetic Document Layout + Textline Dataset
69
+
70
+ This dataset contains **synthetically generated** image-document pairs with detailed layout annotations and ground-truth Dhivehi text extractions.
71
+ It’s designed for document layout analysis, visual document understanding, OCR fine-tuning, and related tasks specifically for Dhivehi script.
72
+
73
+ ***Note: this version image are compressed.***
74
+ ***Raw version πŸ“ **Repository**: [Hugging Face Datasets](https://huggingface.co/datasets/alakxender/od-syn-page-annotations)***
75
+
76
+ ## πŸ“‹ Dataset Summary
77
+
78
+ - **Total Examples**: ~58,738
79
+ - **Image Content**: Synthetic Dhivehi documents generated to simulate real-world layouts, including headlines, textlines, pictures, and captions.
80
+ - **Annotations**:
81
+ - Bounding boxes (`bbox`)
82
+ - Object areas (`area`)
83
+ - Object categories (`category`)
84
+ - Ground-truth parsed text, split into:
85
+ - `headline` (major headings)
86
+ - `textline` (paragraph or text body lines)
87
+ ## ⚠️ Important Note
88
+
89
+ This dataset is **synthetic** β€” no real-world documents or personal data were used. It was generated programmatically to train and evaluate models under controlled conditions, without legal or ethical concerns tied to real-world data.
90
+
91
+ ## 🏷️ Categories
92
+
93
+ | Label ID | Label Name |
94
+ |----------|-------------|
95
+ | 0 | Textline |
96
+ | 1 | Heading |
97
+ | 2 | Picture |
98
+ | 3 | Caption |
99
+ | 4 | Columns |
100
+
101
+ ## πŸ“ Features
102
+
103
+ | Field | Type |
104
+ |----------------------|-----------------------------------------|
105
+ | `image_id` | int64 |
106
+ | `image` | image |
107
+ | `width` | int64 |
108
+ | `height` | int64 |
109
+ | `objects` | List of:
110
+ - `id`: int64
111
+ - `area`: int64
112
+ - `bbox`: [x, y, width, height] (float32)
113
+ - `category`: label (class label 0–4) |
114
+ | `ground_truth.gt_parse` |
115
+ - `headline`: list of strings
116
+ - `textline`: list of strings |
117
+
118
+
119
+ ## πŸ“Š Split
120
+
121
+ | Split | # Examples | Size (bytes) |
122
+ |--------|------------|----------------------|
123
+ | Train | 58,738 | ~84.31 GB (compressed) |
124
+
125
+ ## πŸ“¦ Download
126
+
127
+ - **Download size**: ~93.32 GB
128
+ - **Uncompressed dataset size**: ~84.31 GB
129
+
130
+
131
+ ## πŸ”§ Example Use (with πŸ€— Datasets)
132
+
133
+ ```python
134
+ from datasets import load_dataset
135
+
136
+ dataset = load_dataset("alakxender/od-syn-page-annotations")
137
+
138
+ categories = dataset.features["objects"].feature["category"].names
139
+ id2label = {i: name for i, name in enumerate(categories)}
140
+
141
+ print(id2label)
142
+
143
+ sample = dataset['train'][0]
144
+ print("Image ID:", sample['image_id'])
145
+ print("Image size:", sample['width'], "x", sample['height'])
146
+ print("First object category:", sample['objects']['category'][0])
147
+ print("First headline:", sample['ground_truth']['gt_parse']['headline'][0])
148
+ ```
149
+
150
+ ## πŸ“Š Visualize
151
+
152
+ ```python
153
+ import numpy as np
154
+ from PIL import Image, ImageDraw, ImageFont
155
+ from datasets import load_dataset
156
+
157
+ def get_color(idx):
158
+ palette = [
159
+ "red", "green", "blue", "orange", "purple", "cyan", "magenta", "yellow", "lime", "pink"
160
+ ]
161
+ return palette[idx % len(palette)]
162
+
163
+ def draw_bboxes(sample, id2label, save_path=None):
164
+ """
165
+ Draw bounding boxes and labels on a single dataset sample.
166
+
167
+ Args:
168
+ sample: A dataset example (dict) with 'image' and 'objects'.
169
+ id2label: Mapping from category ID to label name.
170
+ save_path: If provided, saves the image to this path.
171
+
172
+ Returns:
173
+ PIL Image with drawn bounding boxes.
174
+ """
175
+ image = sample["image"]
176
+ annotations = sample["objects"]
177
+
178
+ image = Image.fromarray(np.array(image))
179
+ draw = ImageDraw.Draw(image)
180
+ try:
181
+ font = ImageFont.truetype("arial.ttf", 14)
182
+ except:
183
+ font = ImageFont.load_default()
184
+
185
+ for category, box in zip(annotations["category"], annotations["bbox"]):
186
+ x, y, w, h = box
187
+ color = get_color(category)
188
+ draw.rectangle((x, y, x + w, y + h), outline=color, width=2)
189
+ label = id2label[category]
190
+ bbox = font.getbbox(label)
191
+ text_width = bbox[2] - bbox[0]
192
+ text_height = bbox[3] - bbox[1]
193
+ draw.rectangle([x, y, x + text_width + 4, y + text_height + 2], fill=color)
194
+ draw.text((x + 2, y + 1), label, fill="black", font=font)
195
+
196
+ if save_path:
197
+ image.save(save_path)
198
+ print(f"Saved image to {save_path}")
199
+ else:
200
+ image.show()
201
+
202
+ return image
203
+
204
+ # Load one sample
205
+ dataset = load_dataset("alakxender/od-syn-page-annotations", split="train[:1]")
206
+
207
+ # Get category mapping
208
+ categories = dataset.features["objects"].feature["category"].names
209
+ id2label = {i: name for i, name in enumerate(categories)}
210
+
211
+ # Draw bounding boxes on the first sample
212
+ draw_bboxes(
213
+ sample=dataset[0],
214
+ id2label=id2label,
215
+ save_path="sample_0.png"
216
+ )
217
+ ```