Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,60 +1,128 @@
|
|
| 1 |
---
|
| 2 |
dataset_info:
|
| 3 |
features:
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
dtype: string
|
| 15 |
-
- name: ocr_text
|
| 16 |
-
dtype: string
|
| 17 |
-
- name: params
|
| 18 |
dtype: string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
---
|
| 20 |
|
| 21 |
# OCR-PDF-Degraded Dataset
|
| 22 |
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
##
|
| 26 |
|
| 27 |
-
|
| 28 |
-
- **pdf_filename**: Original PDF from which the image was extracted
|
| 29 |
-
- **image**: The degraded document image (viewable in the Hugging Face dataset viewer)
|
| 30 |
-
- **ocr_text**: Extracted OCR text from the document
|
| 31 |
-
- **params**: A JSON string containing all degradation parameters used to generate the image
|
| 32 |
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
```python
|
|
|
|
| 36 |
from datasets import load_dataset
|
| 37 |
import json
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
#
|
| 43 |
-
|
| 44 |
-
from PIL import Image
|
| 45 |
-
import io
|
| 46 |
|
| 47 |
-
# Get
|
| 48 |
-
|
| 49 |
-
img = Image.open(io.BytesIO(image_data))
|
| 50 |
-
plt.imshow(img)
|
| 51 |
-
plt.axis('off')
|
| 52 |
-
plt.show()
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
params = json.loads(dataset['train'][0]['params'])
|
| 59 |
-
print(params)
|
| 60 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
dataset_info:
|
| 3 |
features:
|
| 4 |
+
- name: page_filename
|
| 5 |
+
dtype: string
|
| 6 |
+
- name: pdf_filename
|
| 7 |
+
dtype: string
|
| 8 |
+
- name: image
|
| 9 |
+
dtype: image
|
| 10 |
+
struct:
|
| 11 |
+
- name: bytes
|
| 12 |
+
dtype: binary
|
| 13 |
+
- name: path
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
dtype: string
|
| 15 |
+
- name: ocr_text
|
| 16 |
+
dtype: string
|
| 17 |
+
- name: params
|
| 18 |
+
dtype: string
|
| 19 |
+
license: apache-2.0
|
| 20 |
+
task_categories:
|
| 21 |
+
- text-generation
|
| 22 |
+
language:
|
| 23 |
+
- fr
|
| 24 |
+
- en
|
| 25 |
+
tags:
|
| 26 |
+
- military
|
| 27 |
+
- defense
|
| 28 |
+
size_categories:
|
| 29 |
+
- 10K<n<100K
|
| 30 |
---
|
| 31 |
|
| 32 |
# OCR-PDF-Degraded Dataset
|
| 33 |
|
| 34 |
+
## Overview
|
| 35 |
+
|
| 36 |
+
This dataset contains synthetically degraded document images paired with their ground truth OCR text. It addresses a critical gap in OCR model training by providing realistic document degradations that simulate real-world conditions encountered in production environments.
|
| 37 |
+
|
| 38 |
+
## Purpose
|
| 39 |
+
|
| 40 |
+
Most OCR models are trained on relatively clean, perfectly scanned documents. However, in real-world applications, especially in the military/defense sector, documents may be poorly scanned, photographed in suboptimal lighting conditions, or degraded due to environmental factors. This dataset aims to:
|
| 41 |
+
|
| 42 |
+
1. Enable the training of more robust OCR models that can handle imperfect document inputs
|
| 43 |
+
2. Establish a standardized benchmark for evaluating OCR performance under various degradation conditions
|
| 44 |
+
3. Bridge the gap between lab performance and real-world deployment for document processing systems
|
| 45 |
+
|
| 46 |
+
## Domain Focus
|
| 47 |
+
|
| 48 |
+
This first iteration focuses specifically on military/defense sector documents. These documents:
|
| 49 |
+
- Contain specialized terminology and formatting
|
| 50 |
+
- Often include tables, diagrams, and structured information
|
| 51 |
+
- May include mission-critical information where accurate OCR is essential
|
| 52 |
+
- Represent a sector where document digitization processes may not always be ideal
|
| 53 |
+
|
| 54 |
+
## Dataset Creation Process
|
| 55 |
+
|
| 56 |
+
The dataset was created through a systematic process of degrading clean PDF documents:
|
| 57 |
+
|
| 58 |
+

|
| 59 |
+
|
| 60 |
+
The process includes:
|
| 61 |
+
1. Starting with clean military/defense PDF documents
|
| 62 |
+
2. Extracting individual pages
|
| 63 |
+
3. Performing OCR on the clean pages to establish ground truth text
|
| 64 |
+
4. Applying various degradation effects to simulate real-world conditions
|
| 65 |
+
5. Recording both the degraded images and the corresponding degradation parameters
|
| 66 |
|
| 67 |
+
## Degradation Parameters
|
| 68 |
|
| 69 |
+
The dataset includes various degradation types:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
+
- **Noise**: Random pixel noise at different intensities
|
| 72 |
+
- **Lighting**: Uneven illumination effects with varying intensities and positions
|
| 73 |
+
- **Perspective**: Distortions simulating non-flat document captures
|
| 74 |
+
- **Artifacts**: Lines, spots, and other common scanner/camera artifacts
|
| 75 |
+
- **Image Quality**: Variations in blur, brightness, contrast, and JPEG compression
|
| 76 |
+
|
| 77 |
+
Each image in the dataset includes specific parameter values, allowing for targeted evaluation and training.
|
| 78 |
+
|
| 79 |
+
## Usage Examples
|
| 80 |
+
|
| 81 |
+
This dataset is ideal for:
|
| 82 |
|
| 83 |
```python
|
| 84 |
+
# Example: Loading and using the dataset
|
| 85 |
from datasets import load_dataset
|
| 86 |
import json
|
| 87 |
|
| 88 |
+
dataset = load_dataset("racineai/ocr-pdf-degraded", split="train")
|
| 89 |
+
|
| 90 |
+
# Access a sample
|
| 91 |
+
sample = dataset[0]
|
| 92 |
|
| 93 |
+
# Get the degraded image
|
| 94 |
+
image = sample["image"]
|
|
|
|
|
|
|
| 95 |
|
| 96 |
+
# Get the ground truth OCR text
|
| 97 |
+
text = sample["ocr_text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
+
# Access degradation parameters (for targeted training/evaluation)
|
| 100 |
+
params = json.loads(sample["params"])
|
| 101 |
+
noise_level = params["noise_level"]
|
| 102 |
|
| 103 |
+
print(noise_level)
|
|
|
|
|
|
|
| 104 |
```
|
| 105 |
+
|
| 106 |
+
## Limitations and Future Work
|
| 107 |
+
|
| 108 |
+
- Current iteration focuses only on military/defense documents
|
| 109 |
+
- Further domain expansion planned for legal, medical, and financial sectors
|
| 110 |
+
- Future versions may include handwritten text degradations
|
| 111 |
+
- Working on expansion to include multi-page document context
|
| 112 |
+
|
| 113 |
+
## Citation
|
| 114 |
+
|
| 115 |
+
If you use this dataset in your research, please cite:
|
| 116 |
+
|
| 117 |
+
```
|
| 118 |
+
@misc{racineai_ocr_pdf_degraded,
|
| 119 |
+
author = {RacineAI},
|
| 120 |
+
title = {OCR-PDF-Degraded: Synthetically Degraded Documents for Robust OCR},
|
| 121 |
+
year = {2025},
|
| 122 |
+
url = {https://huggingface.co/datasets/racineai/ocr-pdf-degraded}
|
| 123 |
+
}
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
## License
|
| 127 |
+
|
| 128 |
+
Apache 2.0
|