CoolFace
Datasetpublic

alakxender/od-syn-page-annotations

πŸ“¦ Dhivehi Synthetic Document Layout + Textline Dataset This dataset contains synthetically generated image-document pairs with detailed layout annotations and ground-truth Dhivehi text extractions.It’s designed for document layout analysis , visual document understanding , OCR fine-tuning, and related tasks specifically for Dhivehi script. πŸ“‹ Dataset Summary Total Examples: ~58,738 Image Content: Synthetic Dhivehi documents generated to simulate real-world… See the full description on the dataset page: https://huggingface.co/datasets/alakxender/od-syn-page-annotations.

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes423downloads
Dataset Card

πŸ“¦ Dhivehi Synthetic Document Layout + Textline Dataset

This dataset contains synthetically generated image-document pairs with detailed layout annotations and ground-truth Dhivehi text extractions. It’s designed for document layout analysis , visual document understanding , OCR fine-tuning, and related tasks specifically for Dhivehi script.

πŸ“‹ Dataset Summary

  • β€”Total Examples: ~58,738
  • β€”Image Content: Synthetic Dhivehi documents generated to simulate real-world layouts, including headlines, textlines, pictures, and captions.
  • β€”Annotations:
  • β€”Bounding boxes (bbox)
  • β€”Object areas (area)
  • β€”Object categories (category)
  • β€”Ground-truth parsed text, split into:
  • β€”headline (major headings)
  • β€”textline (paragraph or text body lines)

⚠️ Important Note

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.

🏷️ Categories

Label IDLabel Name
0Textline
1Heading
2Picture
3Caption
4Columns

πŸ“ Features

FieldType
image_idint64
imageimage
widthint64
heightint64
objectsList of:
  • β€”id: int64
  • β€”area: int64
  • β€”bbox: [x, y, width, height] (float32)
  • β€”category: label (class label 0–4) | | ground_truth.gt_parse |
  • β€”headline: list of strings
  • β€”textline: list of strings |

πŸ“Š Split

Split# ExamplesSize (bytes)
Train58,738~121.95 GB

Also check the compressed version πŸ“ Repository: Hugging Face Datasets

πŸ“¦ Download

The dataset requires ~134.76 GB for download and ~121.95 GB storage after extraction.

πŸ”§ Example Use (with πŸ€— Datasets)

python
from datasets import load_dataset

dataset = load_dataset("alakxender/od-syn-page-annotations")

categories = dataset.features["objects"].feature["category"].names
id2label = {i: name for i, name in enumerate(categories)}

print(id2label)

sample = dataset['train'][0]
print("Image ID:", sample['image_id'])
print("Image size:", sample['width'], "x", sample['height'])
print("First object category:", sample['objects']['category'][0])
print("First headline:", sample['ground_truth']['gt_parse']['headline'][0])

πŸ“Š Visualize

python
import numpy as np
from PIL import Image, ImageDraw, ImageFont
from datasets import load_dataset

def get_color(idx):
    palette = [
        "red", "green", "blue", "orange", "purple", "cyan", "magenta", "yellow", "lime", "pink"
    ]
    return palette[idx % len(palette)]

def draw_bboxes(sample, id2label, save_path=None):
    """
    Draw bounding boxes and labels on a single dataset sample.

    Args:
        sample: A dataset example (dict) with 'image' and 'objects'.
        id2label: Mapping from category ID to label name.
        save_path: If provided, saves the image to this path.

    Returns:
        PIL Image with drawn bounding boxes.
    """
    image = sample["image"]
    annotations = sample["objects"]

    # Convert to PIL Image
    image = Image.fromarray(np.array(image))
    draw = ImageDraw.Draw(image)
    try:
        font = ImageFont.truetype("arial.ttf", 14)
    except:
        font = ImageFont.load_default()

    # Draw boxes and labels
    for category, box in zip(annotations["category"], annotations["bbox"]):
        x, y, w, h = box
        color = get_color(category)
        draw.rectangle((x, y, x + w, y + h), outline=color, width=2)
        label = id2label[category]
        bbox = font.getbbox(label)
        text_width = bbox[2] - bbox[0]
        text_height = bbox[3] - bbox[1]
        draw.rectangle([x, y, x + text_width + 4, y + text_height + 2], fill=color)
        draw.text((x + 2, y + 1), label, fill="black", font=font)

    if save_path:
        image.save(save_path)
        print(f"Saved image to {save_path}")
    else:
        image.show()

    return image

from datasets import load_dataset

# Load one sample
dataset = load_dataset("alakxender/od-syn-page-annotations", split="train[:1]")

# Get category mapping
categories = dataset.features["objects"].feature["category"].names
id2label = {i: name for i, name in enumerate(categories)}

# Draw bounding boxes on the first sample
draw_bboxes(
    sample=dataset[0],
    id2label=id2label,
    save_path="sample_0.png"
)