Dataset Viewer
Auto-converted to Parquet
Search is not available for this dataset
image
imagewidth (px)
1.2k
1.2k

task_categories:

  • image-to-text task_ids:
  • optical-character-recognition
  • text-recognition

Portuguese OCR Dataset

A comprehensive dataset for Portuguese OCR (Optical Character Recognition) generated from classic Portuguese literature with diverse fonts and visual styles.

Dataset Description

This dataset contains 20000 text images for OCR training, created from Portuguese books from Project Gutenberg. Each image contains a complete Portuguese sentence with proper punctuation, rendered with various fonts, backgrounds, and visual styles.

Features

  • Multiple Text Sources: Classic Portuguese literature from Project Gutenberg
  • Complete Sentences: Full sentences with proper punctuation and grammar
  • Font Variety: Multiple fonts from Google Fonts collection
  • Visual Diversity: Various backgrounds, font sizes, colors, and slight rotations
  • High Quality: 1200×150 pixel images (or taller for wrapped text)

Dataset Splits

Split Number of Samples
Train 16000
Validation 2000
Test 2000
Total 20000

Example Sentences

  • Ha um cão vadio, sujo e com fome, cuida-se deste cão e ele deixa de ser vadio, deixa de estar sujo e deixa de ter fome.
  • Um affago previo tempera as traições.
  • Demais, eu tenho algodão nos ouvidos, talvez ouvisse mal, repete o que disseste.

Image Specifications

  • Resolution: 150×1200 pixels
  • Color: RGB
  • Format in HDF5: Numpy arrays
  • Average text length: 82.8 characters

Usage Example

import h5py
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt

# Load the dataset
with h5py.File('train_dataset.h5', 'r') as f:
    # Access images and texts
    images = f['images'][:]
    texts = [t.decode('utf-8') if isinstance(t, bytes) else t for t in f['texts'][:]]
    
    # Display a sample
    idx = np.random.randint(0, len(images))
    print(f"Text: {texts[idx]}")
    
    plt.figure(figsize=(12, 3))
    plt.imshow(images[idx])
    plt.axis('off')
    plt.show()

Dataset Creation Process

This dataset was created through the following steps:

  1. Downloaded and extracted text from Portuguese books via Project Gutenberg
  2. Cleaned and extracted complete sentences with proper punctuation
  3. Generated images with random:
    • Fonts (from Google Fonts collection)
    • Background styles (solid, gradient, noise, pattern)
    • Text positions and slight rotations
    • Font sizes (30-45px)
    • Text colors (dark tones for readability)
  4. Split into train (80%), validation (10%), and test (10%) sets

License

This dataset is derived from public domain books from Project Gutenberg and open-source fonts from Google Fonts. It is released under the Creative Commons Attribution 4.0 International License (CC-BY 4.0).

Citation

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

@dataset{portuguese_ocr_dataset,
  author = {mazafard},
  title = {Portuguese OCR Dataset},
  year = {2025},
  publisher = {Hugging Face},
  url = {https://huggingface.co/datasets/mazafard/portuguese-ocr-dataset}
}

Acknowledgments

Downloads last month
86