mazafard commited on
Commit
2b57f4c
·
verified ·
1 Parent(s): 8bc35ff

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +98 -0
README.md ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Portuguese OCR Dataset
2
+
3
+ A comprehensive dataset for Portuguese OCR (Optical Character Recognition) generated from classic Portuguese literature with diverse fonts and visual styles.
4
+
5
+ ## Dataset Description
6
+
7
+ 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.
8
+
9
+ ### Features
10
+
11
+ - **Multiple Text Sources**: Classic Portuguese literature from Project Gutenberg
12
+ - **Complete Sentences**: Full sentences with proper punctuation and grammar
13
+ - **Font Variety**: Multiple fonts from Google Fonts collection
14
+ - **Visual Diversity**: Various backgrounds, font sizes, colors, and slight rotations
15
+ - **High Quality**: 1200×150 pixel images (or taller for wrapped text)
16
+
17
+ ## Dataset Splits
18
+
19
+ | Split | Number of Samples |
20
+ |-------|------------------|
21
+ | Train | 16000 |
22
+ | Validation | 2000 |
23
+ | Test | 2000 |
24
+ | **Total** | 20000 |
25
+
26
+ ## Example Sentences
27
+
28
+ - 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.
29
+ - Um affago previo tempera as traições.
30
+ - Demais, eu tenho algodão nos ouvidos, talvez ouvisse mal, repete o que disseste.
31
+
32
+ ## Image Specifications
33
+
34
+ - **Resolution**: 150×1200 pixels
35
+ - **Color**: RGB
36
+ - **Format in HDF5**: Numpy arrays
37
+ - **Average text length**: 82.8 characters
38
+
39
+ ## Usage Example
40
+
41
+ ```python
42
+ import h5py
43
+ import numpy as np
44
+ from PIL import Image
45
+ import matplotlib.pyplot as plt
46
+
47
+ # Load the dataset
48
+ with h5py.File('train_dataset.h5', 'r') as f:
49
+ # Access images and texts
50
+ images = f['images'][:]
51
+ texts = [t.decode('utf-8') if isinstance(t, bytes) else t for t in f['texts'][:]]
52
+
53
+ # Display a sample
54
+ idx = np.random.randint(0, len(images))
55
+ print(f"Text: {texts[idx]}")
56
+
57
+ plt.figure(figsize=(12, 3))
58
+ plt.imshow(images[idx])
59
+ plt.axis('off')
60
+ plt.show()
61
+ ```
62
+
63
+ ## Dataset Creation Process
64
+
65
+ This dataset was created through the following steps:
66
+
67
+ 1. Downloaded and extracted text from Portuguese books via Project Gutenberg
68
+ 2. Cleaned and extracted complete sentences with proper punctuation
69
+ 3. Generated images with random:
70
+ - Fonts (from Google Fonts collection)
71
+ - Background styles (solid, gradient, noise, pattern)
72
+ - Text positions and slight rotations
73
+ - Font sizes (30-45px)
74
+ - Text colors (dark tones for readability)
75
+ 4. Split into train (80%), validation (10%), and test (10%) sets
76
+
77
+ ## License
78
+
79
+ 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).
80
+
81
+ ## Citation
82
+
83
+ If you use this dataset in your research, please cite it as:
84
+
85
+ ```
86
+ @dataset{portuguese_ocr_dataset,
87
+ author = {mazafard},
88
+ title = {Portuguese OCR Dataset},
89
+ year = {2025},
90
+ publisher = {Hugging Face},
91
+ url = {https://huggingface.co/datasets/mazafard/portuguese-ocr-dataset}
92
+ }
93
+ ```
94
+
95
+ ## Acknowledgments
96
+
97
+ - Text sources: Project Gutenberg (https://gutenberg.org/)
98
+ - Fonts: Google Fonts (https://fonts.google.com/)