paulpall commited on
Commit
9f8ebb1
Β·
verified Β·
1 Parent(s): 6fba014

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +210 -0
README.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ task_categories:
3
+ - object-detection
4
+ language:
5
+ - et
6
+ tags:
7
+ - Estonia
8
+ - historical-documents
9
+ - coordinates
10
+ - layout-analysis
11
+ - text-detection
12
+ - document-structure
13
+ - transkribus
14
+ - page-analysis
15
+ pretty_name: ArchXAI Page Layouts
16
+ size_categories:
17
+ - n<1K
18
+ ---
19
+
20
+ # πŸ“ ArchXAI Estonian Document Coordinate Dataset
21
+
22
+ ## Dataset Description
23
+
24
+ This dataset contains coordinate annotations for Estonian historical documents, extracted from Transkribus exports. It includes full page images with precise coordinate information for text regions and text lines, designed for text detection, layout analysis, and document structure understanding tasks.
25
+
26
+ ## πŸ“Š Dataset Summary
27
+
28
+ - **Total Examples**: 148 images
29
+ - **Language**: πŸ‡ͺπŸ‡ͺ Estonian
30
+ - **Dataset Size**: ~158 MB
31
+ - **Task**: Text Detection, Layout Analysis, Document Structure Analysis
32
+ - **Domain**: Historical Documents, Archival Materials
33
+ - **Source**: Transkribus PAGE XML exports
34
+
35
+ ## πŸ—‚οΈ Dataset Structure
36
+
37
+ ### πŸ“‹ Features
38
+
39
+ - **image**: Full page image (PIL Image)
40
+ - **text_regions**: Coordinate string for text region polygons in format: `region_1:((x1,y1),(x2,y2),...),region_2:((x1,y1),...)`
41
+ - **text_lines**: Coordinate string for text line polygons in format: `line_1:((x1,y1),(x2,y2),...),line_2:((x1,y1),...)`
42
+ - **document_title**: Source document name
43
+
44
+ ### 🎯 Coordinate Format
45
+
46
+ The coordinates are stored as simple, readable strings:
47
+
48
+ **Text Regions**: Each region is numbered and contains rectangle points
49
+ ```
50
+ region_1:((704,968),(704,2814),(2764,2814),(2764,968)),region_2:((3349,897),(3349,3256),(5284,3256),(5284,897))
51
+ ```
52
+
53
+ **Text Lines**: Each line is numbered and contains polygon points
54
+ ```
55
+ line_1:((237,349),(400,352),(480,405),(500,420)),line_2:((255,483),(379,469),(420,485),(445,500))
56
+ ```
57
+
58
+ ## πŸ’» Usage Examples
59
+
60
+ ### Basic Loading
61
+
62
+ ```python
63
+ from datasets import load_dataset
64
+
65
+ # Load the dataset
66
+ dataset = load_dataset("Rahvusarhiiv/ArchXAI_page_layouts")
67
+
68
+ # Access a sample
69
+ sample = dataset['train'][0]
70
+ image = sample['image']
71
+ text_regions = sample['text_regions']
72
+ text_lines = sample['text_lines']
73
+ document = sample['document_title']
74
+ ```
75
+
76
+ ### Parse Coordinates
77
+
78
+ ```python
79
+ def parse_coordinates(coord_string):
80
+ """Parse coordinate string into list of polygons."""
81
+ regions = []
82
+ if not coord_string:
83
+ return regions
84
+
85
+ # Split by regions/lines
86
+ parts = coord_string.split('),region_') if 'region_' in coord_string else coord_string.split('),line_')
87
+
88
+ for part in parts:
89
+ # Extract coordinates
90
+ if ':(' in part:
91
+ coords_str = part.split(':(')[1] if ':(' in part else part
92
+ coords_str = coords_str.rstrip(')')
93
+
94
+ # Parse coordinate pairs
95
+ coords = []
96
+ pairs = coords_str.split('),(')
97
+ for pair in pairs:
98
+ pair = pair.strip('()')
99
+ if ',' in pair:
100
+ x, y = pair.split(',')
101
+ coords.append((int(x), int(y)))
102
+
103
+ if coords:
104
+ regions.append(coords)
105
+
106
+ return regions
107
+
108
+ # Example usage
109
+ sample = dataset['train'][0]
110
+ text_regions = parse_coordinates(sample['text_regions'])
111
+ text_lines = parse_coordinates(sample['text_lines'])
112
+
113
+ print(f"Found {len(text_regions)} text regions")
114
+ print(f"Found {len(text_lines)} text lines")
115
+ ```
116
+
117
+ ### Visualize Coordinates
118
+
119
+ ```python
120
+ from PIL import Image, ImageDraw
121
+
122
+ def visualize_coordinates(image, text_regions, text_lines):
123
+ """Draw coordinates on image."""
124
+ img_copy = image.copy()
125
+ draw = ImageDraw.Draw(img_copy)
126
+
127
+ # Parse and draw text regions (red)
128
+ regions = parse_coordinates(text_regions)
129
+ for region in regions:
130
+ if len(region) >= 3:
131
+ draw.polygon(region, outline='red', width=2)
132
+
133
+ # Parse and draw text lines (blue)
134
+ lines = parse_coordinates(text_lines)
135
+ for line in lines:
136
+ if len(line) >= 3:
137
+ draw.polygon(line, outline='blue', width=1)
138
+
139
+ return img_copy
140
+
141
+ # Visualize first sample
142
+ sample = dataset['train'][0]
143
+ annotated_image = visualize_coordinates(
144
+ sample['image'],
145
+ sample['text_regions'],
146
+ sample['text_lines']
147
+ )
148
+ annotated_image.show()
149
+ ```
150
+
151
+ ### Filter by Document
152
+
153
+ ```python
154
+ # Filter by specific document
155
+ document_pages = dataset['train'].filter(lambda x: 'Aleksander Warma' in x['document_title'])
156
+
157
+ # Group by document
158
+ from collections import defaultdict
159
+ by_document = defaultdict(list)
160
+ for i, sample in enumerate(dataset['train']):
161
+ by_document[sample['document_title']].append(i)
162
+
163
+ print(f"Documents in dataset: {list(by_document.keys())}")
164
+ ```
165
+
166
+ ## 🎯 Use Cases
167
+
168
+ This dataset is valuable for:
169
+
170
+ - **Text Detection**: Locating text regions and lines in historical documents
171
+ - **Layout Analysis Models**: Training systems to understand document structure
172
+ - **Reading Order Detection**: Understanding the sequence of text elements
173
+ - **Document Digitization**: Preprocessing Estonian archival materials
174
+ - **OCR Pipeline Development**: Creating robust text recognition workflows
175
+ - **Digital Humanities**: Analyzing Estonian historical document layouts
176
+ - **Computer Vision Research**: Document understanding and structure analysis
177
+
178
+ ## πŸ”§ Technical Details
179
+
180
+ ### Coordinate System
181
+ - Coordinates are in pixel space relative to the full page image
182
+ - Origin (0,0) is at top-left corner
183
+ - Polygons are stored as sequences of (x,y) points
184
+ - Text regions typically have 4 points (rectangles)
185
+ - Text lines may have variable number of points following text baseline
186
+
187
+ ### Data Processing
188
+ - Extracted from Transkribus PAGE XML format
189
+ - Coordinate precision maintained from original annotations
190
+ - Images converted to RGB format for consistency
191
+ - Document titles extracted from Transkribus folder structure
192
+
193
+ ## ⚠️ Data Quality Notes
194
+
195
+ - Image quality varies based on historical document preservation
196
+ - Some pages may have irregular text layouts due to historical formatting
197
+ - Coordinate accuracy depends on original Transkribus annotation quality
198
+ - Text regions may overlap or have complex shapes
199
+
200
+ ## 🚫 Limitations
201
+
202
+ - Limited to Estonian language documents
203
+ - Historical document layouts may not represent modern document structures
204
+ - Dataset size is focused on quality over quantity
205
+ - Coordinate formats are optimised for polygon representation
206
+ - Some documents may have incomplete coordinate annotations
207
+
208
+ ## 🀝 Contributing
209
+
210
+ This dataset is part of the ArchXAI project for Estonian archival document analysis. For questions or contributions, please contact the National Archives of Estonia.