Dataset Viewer
Auto-converted to Parquet Duplicate
Search is not available for this dataset
image
imagewidth (px)
2.48k
2.48k
End of preview. Expand in Data Studio
YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/datasets-cards)

IAM_mini Dataset - Fair Handwriting Recognition

A fairness-enhanced mini subset of the IAM (Institute of Applied Mathematics) Handwriting Database with 500 randomly selected samples. Each image is separated into printed and handwritten components for fair VLM evaluation.

Fairness Enhancement

The original IAM dataset contains images with both printed reference text and handwritten content on the same page. This allows Vision Language Models (VLMs) to "cheat" by reading the printed portion rather than performing actual handwriting recognition.

This dataset fixes this fairness issue by:

  1. Automatic boundary detection - Using ink density gradient analysis (91.7% accuracy)
  2. Image separation - Creating two separate PNG files per sample:
    • printed.png - Printed reference text section (for comparison/analysis)
    • handwritten.png - Handwritten content only (for fair VLM evaluation)
  3. Pre-cropping - All 500 images are already cropped and ready to use

Dataset Details

  • Total Samples: 500
  • Total Image Files: 1,000 (500 printed + 500 handwritten)
  • Dataset: IAM Handwriting Database
  • Type: Single-writer forms and multi-writer database
  • Image Size: ~2.1 MB per sample on average
  • Total Size: ~1 GB (including both printed and handwritten)

File Structure

β”œβ”€β”€ README.md
β”œβ”€β”€ iam_mini.json                    # Sample mappings (500 samples)
β”œβ”€β”€ iam_mini_index.json              # Detailed metadata with Line 2 boundaries
β”œβ”€β”€ images/
β”‚   β”œβ”€β”€ printed/
β”‚   β”‚   β”œβ”€β”€ iam_000_a01-000u_printed.png      (245 KB)
β”‚   β”‚   β”œβ”€β”€ iam_000_a01-003u_printed.png
β”‚   β”‚   └── ... (500 printed images)
β”‚   └── handwritten/
β”‚       β”œβ”€β”€ iam_000_a01-000u_handwritten.png  (1.6 MB)
β”‚       β”œβ”€β”€ iam_000_a01-003u_handwritten.png
β”‚       └── ... (500 handwritten images)
└── [loading script automatically generated]

Data Format

iam_mini.json (500 samples)

Each sample contains:

  • sample_id: Unique identifier (e.g., "iam_000_a01-000u")
  • printed_image_path: Path to printed-only image
  • handwritten_image_path: Path to handwritten-only image (for fair evaluation)
  • ground_truth: Empty string (to be filled during evaluation)
  • metadata: Additional information
    • line2: Row number where printed text ends and handwriting begins
    • crop_valid: Whether the separation was validated
    • writer_id: Writer identifier (e.g., "000", "a01")
    • image_size: Original image dimensions [width, height]

iam_mini_index.json (Detailed metadata)

Complete metadata with additional fields for analysis and comparison.

Example sample from iam_mini.json:

{
  "sample_id": "iam_000_a01-000u",
  "printed_image_path": "images/printed/iam_000_a01-000u_printed.png",
  "handwritten_image_path": "images/handwritten/iam_000_a01-000u_handwritten.png",
  "ground_truth": "",
  "metadata": {
    "dataset": "IAM_mini",
    "writer_id": "000",
    "line2": 501,
    "crop_valid": true,
    "image_size": [2144, 1456]
  }
}

Usage

Load the Dataset

from datasets import load_dataset

# Load the dataset
dataset = load_dataset("kenza-ily/iam-mini")

# Access a sample
sample = dataset["train"][0]
print(f"Handwritten Image: {sample['handwritten_image_path']}")
print(f"Printed Image: {sample['printed_image_path']}")
print(f"Writer ID: {sample['metadata']['writer_id']}")
print(f"Sample ID: {sample['sample_id']}")

# Load handwritten image for fair VLM evaluation
from PIL import Image
img = Image.open(sample['handwritten_image_path'])
print(f"Image size: {img.size}")

Fair Handwriting Recognition Benchmark

from datasets import load_dataset
import json

dataset = load_dataset("kenza-ily/iam-mini")

# Evaluate VLMs on fair (handwritten-only) images
print("Fair Handwriting Recognition Benchmark")
print("=====================================")

results = []
for sample in dataset["train"]:
    sample_id = sample['sample_id']
    handwritten_img_path = sample['handwritten_image_path']
    
    # Load handwritten image for evaluation
    img = Image.open(handwritten_img_path)
    
    # Pass only the handwritten portion to your VLM
    # This ensures fair evaluation - no printed text to "cheat" from
    prediction = your_vlm_model.predict(img)
    
    results.append({
        "sample_id": sample_id,
        "prediction": prediction,
        "writer_id": sample['metadata']['writer_id']
    })

# Calculate metrics on fair images
accuracy = sum(1 for r in results if r['prediction'] == get_ground_truth(r['sample_id'])) / len(results)
print(f"Fair VLM Accuracy: {accuracy:.1%}")

Compare Before/After Fairness Fix

# Before: Evaluate on mixed images (unfair - printed + handwritten)
# After: Evaluate on handwritten-only images (fair)

before_accuracy = 85.0  # Example: VLM could read printed text
after_accuracy = 65.0   # Fair evaluation on handwriting only

fairness_impact = before_accuracy - after_accuracy
print(f"Fairness impact: {fairness_impact:.1f}% accuracy drop")

Fairness Details

Line 2 Detection Algorithm

  • Method: Ink density gradient analysis
  • Accuracy: 91.7% on test set
  • Processing: ~6 images/second
  • Validation: Each boundary is validated and stored in metadata

Image Separation Quality

  • Validated: All 1,000 images (500 pairs)
  • Line 2 field: Stores the boundary row for reference
  • Crop valid field: Boolean indicating separation quality

Use Cases

  1. Fair Handwriting Recognition: Evaluate VLMs on actual handwriting without printed reference text
  2. Comparison Studies: Use both images to measure the impact of fairness enforcement
  3. Handwriting Analysis: Study pure handwriting characteristics without printed text interference
  4. Fairness Benchmarking: Reference dataset for fair OCR/handwriting evaluation

Citation

If you use this dataset in your research, please cite:

@dataset{iam_mini_fair_2024,
  title={IAM_mini: Fair Handwriting Recognition Dataset with Separated Printed and Handwritten Content},
  author={Benkirane, Kenza},
  year={2024},
  publisher={Hugging Face Datasets},
  howpublished={https://huggingface.co/datasets/kenza-ily/iam-mini}
}

And cite the original IAM Handwriting Database:

@article{marti2002iam,
  title={The IAM-database: an english sentence database for offline handwriting recognition},
  author={Marti, U-V and Bunke, H},
  journal={International journal on document analysis and recognition},
  volume={5},
  pages={39--46},
  year={2002},
  publisher={Springer}
}

Statistics

Metric Value
Total Samples 500
Total Images 1,000 (500 x 2)
Printed Images 500 (~245 KB avg)
Handwritten Images 500 (~1.6 MB avg)
Total Dataset Size ~1 GB
Line 2 Detection Accuracy 91.7%
Processing Duration 1:21 min
Success Rate 100%

Notes

  • Print-only files are provided for reference and comparison
  • Handwritten-only files should be used for fair VLM evaluation
  • Each sample has metadata indicating the line boundary (Line 2)
  • All images are pre-cropped and ready to use
  • Both image types are available for before/after fairness analysis

License

This dataset follows the original IAM Handwriting Database license.


Dataset Version: 2.0 (Fair Image Cropping) Status: Ready for Benchmarking Last Updated: December 2024

Downloads last month
11