flyingbertman commited on
Commit
459bfd7
·
verified ·
1 Parent(s): 4332a84

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pretty_name: DocBank (sampled) — document pages with token-level OCR ground truth
4
+ task_categories:
5
+ - image-to-text
6
+ - object-detection
7
+ language:
8
+ - en
9
+ size_categories:
10
+ - 1K<n<10K
11
+ tags:
12
+ - docbank
13
+ - ocr
14
+ - document-ai
15
+ - document-layout
16
+ - layout-analysis
17
+ - text-recognition
18
+ - arxiv
19
+ source_datasets:
20
+ - doc-analysis/DocBank
21
+ ---
22
+
23
+ # DocBank (sampled) — document pages + exact OCR ground truth
24
+
25
+ A sampled, reshaped mirror of [DocBank](https://github.com/doc-analysis/DocBank) (Li et al., COLING 2020), packaged for one-row-per-page ingestion. The upstream release is 54 GB with page images split across a **ten-part** archive (`DocBank_500K_ori_img.zip.001`…`.010`) and annotations as a separate 3 GB zip of per-page `.txt` files. This mirror carries a small cut — **5,000 train + 1,000 test pages** — with images repackaged into a single zip per split and the token annotations reshaped into gzipped JSONL, so a pipeline can fetch one split and join image ↔ annotation without reassembling a multi-part archive or parsing thousands of loose text files.
26
+
27
+ Re-hosted under Heliosoph for ingestion-pipeline stability; the page pixels and token ground truth are DocBank's, unchanged in content. Pin a revision for reproducible fetches.
28
+
29
+ Credit: Minghao Li, Yiheng Xu, Lei Cui, Shaohan Huang, Furu Wei, Zhoujun Li, Ming Zhou (DocBank). Source documents are LaTeX submissions on arXiv.org.
30
+
31
+ ## Why a mirror?
32
+
33
+ Three frictions make raw DocBank awkward to ingest:
34
+
35
+ 1. **Ten-part split zip.** The images ship as `*.zip.001` … `*.zip.010`; you must download all ~54 GB and reassemble before a single page is readable.
36
+ 2. **Loose per-page text files.** Annotations are one `.txt` per page (tab-separated tokens) inside a 3 GB zip — millions of tiny files.
37
+ 3. **Scale.** 500K pages is far more than a test corpus needs.
38
+
39
+ This mirror resolves all three: a bounded sample, images as one zip per split, and annotations pre-joined into JSONL (one page per line). The token text and boxes are byte-faithful to DocBank's `.txt` ground truth.
40
+
41
+ ## What this repo contains
42
+
43
+ ```
44
+ docbank-train-images.zip # 5,000 page images (PNG/JPG), zip entry name == page_id + ext
45
+ docbank-train.jsonl.gz # 5,000 lines, one JSON object per page
46
+ docbank-test-images.zip # 1,000 page images
47
+ docbank-test.jsonl.gz # 1,000 lines
48
+ ```
49
+
50
+ ### Annotation JSONL — one page per line
51
+
52
+ ```json
53
+ {
54
+ "page_id": "2004.xxxxx.tar_2004.01234.gz_paper_3_ori",
55
+ "image_file": "2004.xxxxx.tar_2004.01234.gz_paper_3_ori.jpg",
56
+ "width": 612,
57
+ "height": 792,
58
+ "text": "Full-page reading-order text, tokens space-joined ...",
59
+ "tokens": [
60
+ {"text": "Attention", "x0": 120, "y0": 88, "x1": 210, "y1": 104, "label": "title", "font": "NimbusRomNo9L-Medi"}
61
+ ]
62
+ }
63
+ ```
64
+
65
+ - `image_file` is the **exact** entry name inside the images zip — join on it directly, no filename parsing.
66
+ - `text` is every token joined by spaces in reading order — ready for an OCR-vs-truth diff.
67
+ - `tokens[]` preserves DocBank's per-token ground truth: `text`, the bounding box `(x0,y0)`–`(x1,y1)` **normalized to 0–1000**, one of twelve semantic `label`s, and the `font`.
68
+
69
+ ### The twelve semantic labels
70
+
71
+ `title`, `author`, `abstract`, `paragraph`, `section`, `list`, `caption`, `equation`, `figure`, `table`, `reference`, `footer`.
72
+
73
+ ## ⚠️ Ground truth is machine-perfect, not human
74
+
75
+ DocBank's labels come from the LaTeX **source**, not from reading the pixels. The transcription is exact by construction — but it reflects source tokenization (ligatures, hyphenation, math markup) rather than what a pixel-level OCR model would emit. Evaluate with a fuzzy / normalized-edit-distance metric, not exact string match. Bounding boxes are in a 0–1000 normalized space; multiply by `width/1000` and `height/1000` to project onto the image.
76
+
77
+ ## How to use
78
+
79
+ ```python
80
+ import gzip, json, zipfile, io
81
+ from PIL import Image
82
+
83
+ # annotations
84
+ with gzip.open("docbank-test.jsonl.gz", "rt", encoding="utf-8") as f:
85
+ pages = [json.loads(line) for line in f]
86
+ print(len(pages), pages[0]["text"][:200])
87
+
88
+ # images — join by image_file
89
+ with zipfile.ZipFile("docbank-test-images.zip") as z:
90
+ img = Image.open(io.BytesIO(z.read(pages[0]["image_file"])))
91
+ print(img.size, "vs", (pages[0]["width"], pages[0]["height"]))
92
+ ```
93
+
94
+ ## Dataset specs
95
+
96
+ | | Spec |
97
+ |---|---|
98
+ | Pages | 5,000 train / 1,000 test (sampled from DocBank's official splits) |
99
+ | Row granularity | one page (image + full text + token array) |
100
+ | Bounding boxes | per token, normalized to 0–1000 |
101
+ | Semantic labels | 12 (title / author / abstract / paragraph / section / list / caption / equation / figure / table / reference / footer) |
102
+ | Domain | academic papers (arXiv), English, two-column + equations |
103
+ | Format | images as zip per split; annotations as gzipped JSONL |
104
+ | Ground truth | machine-exact (from LaTeX source) — use fuzzy scoring |
105
+
106
+ ## When to pick DocBank
107
+
108
+ - **Document OCR eval**: run a recognizer over the page image, diff against the exact `text`. Real printed pages, not synthetic, not scene text.
109
+ - **Layout / detection**: token boxes with semantic labels support detection and reading-order experiments.
110
+ - **Document-AI prototyping**: per-token text + box + role is the shape LayoutLM-style models consume.
111
+
112
+ For photographed text in the wild use **TextOCR** / **HierText**; for receipts, **CORD**; for isolated handwritten characters, **EMNIST**.
113
+
114
+ ## License
115
+
116
+ **Apache-2.0**, as released by the DocBank authors. Permits commercial use, modification, and redistribution with attribution. The underlying documents are arXiv submissions used under their distribution terms; cite the DocBank paper and arXiv.
117
+
118
+ - Paper: [DocBank: A Benchmark Dataset for Document Layout Analysis](https://arxiv.org/abs/2006.01038)
119
+ - Upstream: [doc-analysis/DocBank](https://github.com/doc-analysis/DocBank) · [liminghao1630/DocBank](https://huggingface.co/datasets/liminghao1630/DocBank)
docbank-test-images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1ad9ff82918e79e1c855e5d67589d67cfad9c6c32614378c35e11c01a4d354b
3
+ size 98012648
docbank-test.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:550f00f6a0211a20c284f2e93655ca297456eda6e98c953d9d68e481422cf109
3
+ size 8378946
docbank-train-images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8669edfb56089f8e7aea5a18b44410059a5a5272a63edd2ac6f391cc07083867
3
+ size 500895433
docbank-train.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:710c8a94ae136b78df6e3fbcfa8766f879988c29265464f22e81b399dc21b3b0
3
+ size 42220313