Datasets:
File size: 3,617 Bytes
54a8364 414548b e4c0104 414548b 54a8364 414548b e4c0104 414548b e4c0104 414548b e4c0104 414548b e4c0104 414548b e4c0104 414548b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | ---
license: cc-by-4.0
language:
- km
- en
task_categories:
- object-detection
tags:
- khmer
- text-detection
- ocr
- document-analysis
- yolo
- synthetic
- scene-text
pretty_name: Khmer Text Detection (Ultimate)
size_categories:
- 10K<n<100K
---
# Textline Detection — Ultimate Dataset
A large-scale, multi-source dataset for **textline detection** using YOLO-format bounding box annotations.
Combines real scene text, document layout images, and synthetically generated Khmer document images.
---
## Dataset Summary
| Split | Images |
|-------|--------|
| Train | 30,658 |
| Val | 2,764 |
| **Total** | **33,422** |
### Classes
| ID | Name | Description |
|----|------|-------------|
| 0 | `text_line` | A line of Khmer or mixed-script text |
| 1 | `image` | An embedded image/figure region within a document |
---
## Data Sources
### 1. Real Scene Text
Images captured in natural environments — street signs, storefronts, billboards, and handwritten Khmer documents.
Derived from the **DonkeySmall** base dataset (~26K images).
### 2. Document Layout
Images from the **DocLayNet** multi-class document layout corpus, re-labelled for the two-class schema.
Covers documents: official reports, newspapers, and books.
### 3. Synthetic Khmer Documents
Programmatically generated document images using custom Khmer text rendering pipelines.
Fonts, sizes, backgrounds, and layouts are randomised. Labels are auto-generated (zero annotation cost).
---
## Annotation Format
Labels follow **YOLO v8** format — coordinates normalised to `[0, 1]`:
```
<class_id> <cx> <cy> <width> <height>
```
The `annotations` field is a JSON-serialised list:
```json
[
{"class_id": 0, "cx": 0.512, "cy": 0.234, "w": 0.310, "h": 0.045},
{"class_id": 1, "cx": 0.720, "cy": 0.600, "w": 0.200, "h": 0.250}
]
```
---
## Dataset Fields
| Field | Type | Description |
|-------|------|-------------|
| `image` | `Image` | Decoded PIL image |
| `image_path` | `string` | Original file path at collection time |
| `source` | `string` | `real_scene_text` / `doclaynet_khmer` / `synthetic_khmer_doc` |
| `split` | `string` | `train` or `val` |
| `annotations` | `string` | JSON list of YOLO bounding boxes |
| `num_objects` | `int32` | Number of annotated objects |
---
## Usage
```python
from datasets import load_dataset
ds = load_dataset("Darayut/Multilingual-Textline-Detection-Dataset")
sample = ds["train"][0]
print(sample["source"], sample["num_objects"])
sample["image"].show()
```
### Convert back to YOLO label files
```python
import json
from pathlib import Path
def save_labels(split, out_dir):
Path(out_dir).mkdir(parents=True, exist_ok=True)
for row in ds[split]:
stem = Path(row["image_path"]).stem
anns = json.loads(row["annotations"])
with open(f"{out_dir}/{stem}.txt", "w") as f:
for a in anns:
f.write(f"{a['class_id']} {a['cx']:.6f} {a['cy']:.6f} {a['w']:.6f} {a['h']:.6f}\n")
save_labels("train", "labels/train")
save_labels("val", "labels/val")
```
### YAML config for YOLOv8 training
```yaml
train: /path/to/images/train
val: /path/to/images/val
nc: 2
names:
0: text_line
1: image
```
---
## Limitations
- Synthetic images may not capture all real-world degradation (blur, skew, lighting variation).
- Scene-text labels are semi-automatic and may have occasional missed detections.
- Dataset is primarily Khmer script; other scripts appear only incidentally.
---
## License
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) — free to use, share, and adapt with attribution.
---
|