EvitFan commited on
Commit
2944e72
·
verified ·
1 Parent(s): f23904f

Update ReadME.md

Browse files
Files changed (1) hide show
  1. README.md +226 -64
README.md CHANGED
@@ -1,64 +1,226 @@
1
- ---
2
- license: mit
3
- configs:
4
- - config_name: default
5
- data_files:
6
- - split: train
7
- path: data/train-*
8
- - split: val
9
- path: data/val-*
10
- - split: test
11
- path: data/test-*
12
- dataset_info:
13
- features:
14
- - name: id
15
- dtype: int64
16
- - name: image_id
17
- dtype: string
18
- - name: image
19
- dtype: image
20
- - name: text
21
- dtype: string
22
- - name: caption
23
- dtype: string
24
- - name: prompt
25
- dtype: string
26
- - name: split
27
- dtype: string
28
- - name: ocr_confidence
29
- dtype: float64
30
- - name: ocr_backend
31
- dtype: string
32
- - name: caption_model
33
- dtype: string
34
- - name: source
35
- dtype: string
36
- - name: sharpness
37
- dtype: float64
38
- - name: brightness
39
- dtype: float64
40
- - name: contrast
41
- dtype: float64
42
- - name: resolution_w
43
- dtype: int64
44
- - name: resolution_h
45
- dtype: int64
46
- - name: text_length
47
- dtype: int64
48
- - name: word_count
49
- dtype: int64
50
- - name: phrase_reconstructed
51
- dtype: bool
52
- splits:
53
- - name: train
54
- num_bytes: 58573006
55
- num_examples: 800
56
- - name: val
57
- num_bytes: 6821157
58
- num_examples: 100
59
- - name: test
60
- num_bytes: 6848431
61
- num_examples: 100
62
- download_size: 72132017
63
- dataset_size: 72242594
64
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ configs:
4
+ - config_name: default
5
+ data_files:
6
+ - split: train
7
+ path: data/train-*
8
+ - split: val
9
+ path: data/val-*
10
+ - split: test
11
+ path: data/test-*
12
+ dataset_info:
13
+ features:
14
+ - name: id
15
+ dtype: int64
16
+ - name: image_id
17
+ dtype: string
18
+ - name: image
19
+ dtype: image
20
+ - name: text
21
+ dtype: string
22
+ - name: caption
23
+ dtype: string
24
+ - name: prompt
25
+ dtype: string
26
+ - name: split
27
+ dtype: string
28
+ - name: ocr_confidence
29
+ dtype: float64
30
+ - name: ocr_backend
31
+ dtype: string
32
+ - name: caption_model
33
+ dtype: string
34
+ - name: source
35
+ dtype: string
36
+ - name: sharpness
37
+ dtype: float64
38
+ - name: brightness
39
+ dtype: float64
40
+ - name: contrast
41
+ dtype: float64
42
+ - name: resolution_w
43
+ dtype: int64
44
+ - name: resolution_h
45
+ dtype: int64
46
+ - name: text_length
47
+ dtype: int64
48
+ - name: word_count
49
+ dtype: int64
50
+ - name: phrase_reconstructed
51
+ dtype: bool
52
+ splits:
53
+ - name: train
54
+ num_bytes: 58573006
55
+ num_examples: 800
56
+ - name: val
57
+ num_bytes: 6821157
58
+ num_examples: 100
59
+ - name: test
60
+ num_bytes: 6848431
61
+ num_examples: 100
62
+ download_size: 72132017
63
+ dataset_size: 72242594
64
+ task_categories:
65
+ - image-to-text
66
+ - text-to-image
67
+ language:
68
+ - en
69
+ tags:
70
+ - ocr
71
+ - image-captioning
72
+ - text-rendering
73
+ - synthetic
74
+ - blip2
75
+ - easyocr
76
+ - flux
77
+ size_categories:
78
+ - 1K<n<10K
79
+ source_datasets:
80
+ - stzhao/AnyWord-3M
81
+ ---
82
+
83
+ # Text-in-Image OCR Dataset
84
+
85
+ *Built for **Project 12 — Efficient Image Generation**, as part of the ENSTA course [CSC_5IA21](https://giannifranchi.github.io/CSC_5IA21.html)*
86
+
87
+ **Team:** Adam Gassem · Asma Walha · Achraf Chaouch · Takoua Ben Aissa · Amaury Lorin
88
+ **Tutors:** Arturo Mendoza Quispe · Nacim Belkhir
89
+
90
+ ---
91
+
92
+ ## Dataset Summary
93
+
94
+ A curated text-in-image dataset designed for fine-tuning text-to-image generative models (e.g. FLUX, Stable Diffusion, ControlNet) on accurate **text rendering**. Each sample pairs a real-world image containing readable text with:
95
+
96
+ - a verified OCR transcription (EasyOCR),
97
+ - a visual caption (BLIP-2),
98
+ - and a training prompt that embeds the OCR text verbatim.
99
+
100
+ Images are sourced from [AnyWord-3M](https://huggingface.co/datasets/stzhao/AnyWord-3M) and pass a rigorous multi-step quality pipeline before inclusion.
101
+
102
+ ---
103
+
104
+ ## Dataset Structure
105
+
106
+ | Split | Size |
107
+ |-------|------|
108
+ | train | 800 samples |
109
+ | val | 100 samples |
110
+ | test | 100 samples |
111
+
112
+ ### Fields
113
+
114
+ | Field | Type | Description |
115
+ |-------|------|-------------|
116
+ | `image` | Image | The filtered image (512 px, JPEG) |
117
+ | `text` | string | Verified OCR text found in the image |
118
+ | `caption` | string | General visual description generated by BLIP-2 |
119
+ | `prompt` | string | Training prompt embedding the OCR text verbatim |
120
+ | `ocr_confidence` | float | EasyOCR confidence score (0–100) |
121
+ | `ocr_backend` | string | OCR engine used (`easyocr`) |
122
+ | `caption_model` | string | Captioning model used (`blip2` or `blip`) |
123
+ | `source` | string | AnyWord-3M subset of origin |
124
+ | `sharpness` | float | Laplacian variance of the image |
125
+ | `brightness` | float | Mean pixel brightness |
126
+ | `contrast` | float | Pixel standard deviation |
127
+ | `resolution_w` / `resolution_h` | int | Image dimensions in pixels |
128
+ | `text_length` | int | Character count of the OCR text |
129
+ | `word_count` | int | Word count of the OCR text |
130
+ | `phrase_reconstructed` | bool | Whether the full phrase was expanded beyond the bounding box |
131
+
132
+ ### Sample record
133
+
134
+ ```json
135
+ {
136
+ "image": "<PIL.Image>",
137
+ "text": "OPEN",
138
+ "caption": "A storefront with a neon sign above the door.",
139
+ "prompt": "A storefront with a neon sign above the door, with the text \"OPEN\" clearly visible",
140
+ "ocr_confidence": 87.5,
141
+ "source": "AnyWord-3M/laion",
142
+ "sharpness": 142.3,
143
+ "resolution_w": 512,
144
+ "resolution_h": 384
145
+ }
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Usage
151
+
152
+ ```python
153
+ from datasets import load_dataset
154
+
155
+ ds = load_dataset("your-org/your-dataset-name")
156
+
157
+ # Access a training sample
158
+ sample = ds["train"][0]
159
+ print(sample["prompt"])
160
+ sample["image"].show()
161
+ ```
162
+
163
+ For fine-tuning with the prompt field:
164
+
165
+ ```python
166
+ for sample in ds["train"]:
167
+ image = sample["image"] # PIL image
168
+ prompt = sample["prompt"] # text-conditioned training caption
169
+ text = sample["text"] # ground-truth OCR string
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Creation Pipeline
175
+
176
+ Images are drawn from AnyWord-3M (streamed) and pass through the following stages:
177
+
178
+ ```
179
+ AnyWord-3M stream
180
+
181
+
182
+ 1. Annotation filtering → valid, short, English text regions only
183
+
184
+
185
+ 2. Image quality gate → resolution ≥ 256 px, sharpness ≥ 80,
186
+ brightness 30–230, contrast ≥ 20
187
+
188
+
189
+ 3. EasyOCR verify → confirm annotated text is readable (conf ≥ 0.40)
190
+
191
+
192
+ 4. EasyOCR reconstruct → expand to the full visible phrase
193
+
194
+
195
+ 5. BLIP-2 caption → general visual description
196
+
197
+
198
+ 6. Prompt construction → natural sentence with OCR text in quotes
199
+
200
+
201
+ 7. Split & save → 80 % train / 10 % val / 10 % test
202
+ ```
203
+
204
+ ---
205
+
206
+ ## Source Subsets
207
+
208
+ | Subset | Description |
209
+ |--------|-------------|
210
+ | `laion` | Web-crawled natural images |
211
+ | `OCR_COCO_Text` | COCO scene text |
212
+ | `OCR_mlt2019` | Multi-language (English filtered) |
213
+ | `OCR_Art` | Artistic / designed text |
214
+
215
+ ---
216
+
217
+ ## Citation & Project
218
+
219
+ This dataset was produced as part of the **Efficient Image Generation** project at ENSTA Paris.
220
+ Full methodology, training experiments, and inference benchmarks are documented in the [project report](https://drive.google.com/file/d/1ay4-cBOSt4LbLhwgQ0gBykda1Bu0HUXY/view?usp=drive_link).
221
+
222
+ ---
223
+
224
+ ## License
225
+
226
+ Released under the **MIT License** — free to use, modify, and distribute without restriction. Note that the AnyWord-3M source dataset and BLIP-2 model are subject to their own respective licenses on HuggingFace.