Datasets:
Tasks:
Image Classification
Modalities:
Image
Formats:
parquet
Sub-tasks:
multi-label-image-classification
Size:
10K - 100K
License:
Add the remaining shards, full card, and drop the loading script
Browse filesConsolidates the split-across-PRs upload: the remaining train shards and the test split are copied in from the sibling PR so this branch holds the complete dataset.
- README.md +38 -20
- data/test-00000-of-00026.parquet +3 -0
- data/test-00001-of-00026.parquet +3 -0
- data/test-00002-of-00026.parquet +3 -0
- data/test-00003-of-00026.parquet +3 -0
- data/test-00004-of-00026.parquet +3 -0
- data/test-00005-of-00026.parquet +3 -0
- data/test-00006-of-00026.parquet +3 -0
- data/test-00007-of-00026.parquet +3 -0
- data/test-00008-of-00026.parquet +3 -0
- data/test-00009-of-00026.parquet +3 -0
- data/test-00010-of-00026.parquet +3 -0
- data/test-00011-of-00026.parquet +3 -0
- data/test-00012-of-00026.parquet +3 -0
- data/test-00013-of-00026.parquet +3 -0
- data/test-00014-of-00026.parquet +3 -0
- data/test-00015-of-00026.parquet +3 -0
- data/test-00016-of-00026.parquet +3 -0
- data/test-00017-of-00026.parquet +3 -0
- data/test-00018-of-00026.parquet +3 -0
- data/test-00019-of-00026.parquet +3 -0
- data/test-00020-of-00026.parquet +3 -0
- data/test-00021-of-00026.parquet +3 -0
- data/test-00022-of-00026.parquet +3 -0
- data/test-00023-of-00026.parquet +3 -0
- data/test-00024-of-00026.parquet +3 -0
- data/test-00025-of-00026.parquet +3 -0
- data/train-00050-of-00064.parquet +3 -0
- data/train-00051-of-00064.parquet +3 -0
- data/train-00052-of-00064.parquet +3 -0
- data/train-00053-of-00064.parquet +3 -0
- data/train-00054-of-00064.parquet +3 -0
- data/train-00055-of-00064.parquet +3 -0
- data/train-00056-of-00064.parquet +3 -0
- data/train-00057-of-00064.parquet +3 -0
- data/train-00058-of-00064.parquet +3 -0
- data/train-00059-of-00064.parquet +3 -0
- data/train-00060-of-00064.parquet +3 -0
- data/train-00061-of-00064.parquet +3 -0
- data/train-00062-of-00064.parquet +3 -0
- data/train-00063-of-00064.parquet +3 -0
- early_printed_books_font_detection.py +0 -131
README.md
CHANGED
|
@@ -4,30 +4,30 @@ dataset_info:
|
|
| 4 |
- name: image
|
| 5 |
dtype: image
|
| 6 |
- name: labels
|
| 7 |
-
|
| 8 |
class_label:
|
| 9 |
names:
|
| 10 |
-
0: greek
|
| 11 |
-
1: antiqua
|
| 12 |
-
2: other_font
|
| 13 |
-
3: not_a_font
|
| 14 |
-
4: italic
|
| 15 |
-
5: rotunda
|
| 16 |
-
6: textura
|
| 17 |
-
7: fraktur
|
| 18 |
-
8: schwabacher
|
| 19 |
-
9: hebrew
|
| 20 |
-
10: bastarda
|
| 21 |
-
11: gotico_antiqua
|
| 22 |
splits:
|
| 23 |
-
- name: test
|
| 24 |
-
num_bytes: 2345451
|
| 25 |
-
num_examples: 10757
|
| 26 |
- name: train
|
| 27 |
-
num_bytes:
|
| 28 |
num_examples: 24866
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
annotations_creators:
|
| 32 |
- expert-generated
|
| 33 |
language: []
|
|
@@ -44,6 +44,13 @@ task_categories:
|
|
| 44 |
- image-classification
|
| 45 |
task_ids:
|
| 46 |
- multi-label-image-classification
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
---
|
| 48 |
|
| 49 |
# Early Printed Books Font Detection
|
|
@@ -106,7 +113,18 @@ Counted from `labels-training.csv` and `labels-test.csv` in the Zenodo deposit.
|
|
| 106 |
|
| 107 |
**`not_a_font` is not simply "no text".** It co-occurs with a font label on 567 training and 97 test pages, so it marks non-textual content on a page rather than the absence of type. Two training rows (`bsb00031003_15.jpg`, `bsb10199589_13.jpg`) have no label at all and load with an empty `labels` sequence.
|
| 108 |
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
## Licence
|
| 112 |
|
|
|
|
| 4 |
- name: image
|
| 5 |
dtype: image
|
| 6 |
- name: labels
|
| 7 |
+
list:
|
| 8 |
class_label:
|
| 9 |
names:
|
| 10 |
+
'0': greek
|
| 11 |
+
'1': antiqua
|
| 12 |
+
'2': other_font
|
| 13 |
+
'3': not_a_font
|
| 14 |
+
'4': italic
|
| 15 |
+
'5': rotunda
|
| 16 |
+
'6': textura
|
| 17 |
+
'7': fraktur
|
| 18 |
+
'8': schwabacher
|
| 19 |
+
'9': hebrew
|
| 20 |
+
'10': bastarda
|
| 21 |
+
'11': gotico_antiqua
|
| 22 |
splits:
|
|
|
|
|
|
|
|
|
|
| 23 |
- name: train
|
| 24 |
+
num_bytes: 31799485655
|
| 25 |
num_examples: 24866
|
| 26 |
+
- name: test
|
| 27 |
+
num_bytes: 12966068036
|
| 28 |
+
num_examples: 10757
|
| 29 |
+
download_size: 44768768396
|
| 30 |
+
dataset_size: 44765553691
|
| 31 |
annotations_creators:
|
| 32 |
- expert-generated
|
| 33 |
language: []
|
|
|
|
| 44 |
- image-classification
|
| 45 |
task_ids:
|
| 46 |
- multi-label-image-classification
|
| 47 |
+
configs:
|
| 48 |
+
- config_name: default
|
| 49 |
+
data_files:
|
| 50 |
+
- split: train
|
| 51 |
+
path: data/train-*
|
| 52 |
+
- split: test
|
| 53 |
+
path: data/test-*
|
| 54 |
---
|
| 55 |
|
| 56 |
# Early Printed Books Font Detection
|
|
|
|
| 113 |
|
| 114 |
**`not_a_font` is not simply "no text".** It co-occurs with a font label on 567 training and 97 test pages, so it marks non-textual content on a page rather than the absence of type. Two training rows (`bsb00031003_15.jpg`, `bsb10199589_13.jpg`) have no label at all and load with an empty `labels` sequence.
|
| 115 |
|
| 116 |
+
```python
|
| 117 |
+
from datasets import load_dataset
|
| 118 |
+
|
| 119 |
+
ds = load_dataset("biglam/early_printed_books_font_detection", split="train")
|
| 120 |
+
row = ds[0]
|
| 121 |
+
row["image"] # the page scan
|
| 122 |
+
row["labels"] # one to five font groups, e.g. [1, 5]
|
| 123 |
+
ds.features["labels"].feature.int2str(row["labels"])
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
Pages are high-resolution scans, so stream the dataset if you do not want the whole
|
| 127 |
+
thing on disk: `load_dataset(..., streaming=True)`.
|
| 128 |
|
| 129 |
## Licence
|
| 130 |
|
data/test-00000-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e60caf2e17af9fd4cec0b2709f4b69b9830739dbcd8826d8c8082eec2f99a925
|
| 3 |
+
size 489724430
|
data/test-00001-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:39f2b2031ab81b80ba291db679eff71e6d06baedc35a44f84559cc6ee790a25c
|
| 3 |
+
size 473492143
|
data/test-00002-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:523eba7dd7368404497bcf773be0425a17be7220c3c256f78a68d32d88da78c4
|
| 3 |
+
size 495387783
|
data/test-00003-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8064619051c9726bef114f182b0c4adb6644b6d8623fe7f14921a5191a718679
|
| 3 |
+
size 481940581
|
data/test-00004-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a93566ff948dc7d8e3977139c72a3aa3e157144bf8af76e46c877fa0db06cf04
|
| 3 |
+
size 503910296
|
data/test-00005-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9cede1305f9a3079894550c4d964ca24e38b225748595081fcc9e24342808b8b
|
| 3 |
+
size 491245032
|
data/test-00006-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:673c655c997a05b79fa89b1ef0c15891fde7d441e68cebf57137572374c25460
|
| 3 |
+
size 501390282
|
data/test-00007-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:772848c6e6315a141bb6c2da73f835aa7bb58cbe581890ee3273263b7282b43e
|
| 3 |
+
size 486728227
|
data/test-00008-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:37ad32c3b98d3333e8932f373256340a0b622a3a66a51696985dbaef326524ca
|
| 3 |
+
size 518803230
|
data/test-00009-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a2efb3e0be3bbe2918156762710714fd6a29e5887f01a2193276aae6724d270e
|
| 3 |
+
size 510805038
|
data/test-00010-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:747087cc5acfcb977f0165e19f731ba405ab707a6e880d45be0b4c8296d26a74
|
| 3 |
+
size 513952071
|
data/test-00011-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9611c839a1c32bce56ba3f34d2737fc4476d6ca94e0fb9b02d23b7291540c84
|
| 3 |
+
size 527033466
|
data/test-00012-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ac8a0f09e22da59b0583a3fc1aef64d9765429beec8398ff33e0dfffaecf2d4f
|
| 3 |
+
size 502878548
|
data/test-00013-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d0e1fb651aca1b3499545960f45e321ef927ae66d7227995e32e43ef6ad0e14a
|
| 3 |
+
size 504060342
|
data/test-00014-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d3f451764c4f1931df5f9a428b68a3887527921ef7fb55651525bf075babb3af
|
| 3 |
+
size 525476760
|
data/test-00015-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6583722f69e683bbec26441ade1756694b6f2dcb6ed3b054db06c2ef7b755907
|
| 3 |
+
size 510796897
|
data/test-00016-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:33e22c40a8b7488b3e9a500b5a811db27668cc723d17b4e6f8a03484e8a3bd6d
|
| 3 |
+
size 518543308
|
data/test-00017-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:18db2ba79217bcad20f4945f1fea537a73a4fec9635def91cddf8916caef7cbd
|
| 3 |
+
size 475773301
|
data/test-00018-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8f8c34787da939ea3daa61f4309fdf4b8896e3ae8b1f8a6a9f0421c53c90d842
|
| 3 |
+
size 475072133
|
data/test-00019-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:79709df781dc9754d669b00cbca8f9fc18fb380b062210abdbfe1097a775eeb2
|
| 3 |
+
size 492662969
|
data/test-00020-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bc2497b85240fa7a8054a368e4bd89bda23dc17d280e38dd28e809aeea11f3b1
|
| 3 |
+
size 467040213
|
data/test-00021-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1aa4517c4e9db8391244f25b2a2032587756fc1a376d61934d045c8530845a23
|
| 3 |
+
size 516806372
|
data/test-00022-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d8a54748a56cf147458d0214706d65f4d3506d3a74b5f1b5b398ac2ebdd90389
|
| 3 |
+
size 493063785
|
data/test-00023-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e62b7dcb36e5965f9682b50cc6e1cca5683c90f34d92b11ebca93d882221e861
|
| 3 |
+
size 507513951
|
data/test-00024-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3bd11f7eee9969413363c6bb857e22090dd7be18f4b64c43ce2af2f02a2ba8f1
|
| 3 |
+
size 491993305
|
data/test-00025-of-00026.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f0c242aa936b5d4e930666e3ef6b74f53b1d6cb57c8f53148f18f69a0ab520ec
|
| 3 |
+
size 490966175
|
data/train-00050-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:304fe7bc895eafd11078bd05edf9684e472ac4715dbc9afd8f7a2ee134905a48
|
| 3 |
+
size 588561552
|
data/train-00051-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:af02875c4b1d7ed167483c7b84418a1cbd0bf5dc82a3d915bac327131e793f95
|
| 3 |
+
size 519482084
|
data/train-00052-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9bdbaab925584a48bfb60c07dbc76cd18099d88d1880b1a7df0449ba1046734
|
| 3 |
+
size 481881586
|
data/train-00053-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8d68c786ac68628f37e33edf0b1b36fa2f934a508f5f9961cfdf974daeee1b7f
|
| 3 |
+
size 569311630
|
data/train-00054-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f3f0521cef1b6cd07ece31c2465e533fde476abc7492c000086df391b5233710
|
| 3 |
+
size 502208300
|
data/train-00055-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1bbb34d8422732033a5677d2c787a5d13f3b9c25c99a8351984c0ef08ddd9c13
|
| 3 |
+
size 475841199
|
data/train-00056-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4574cc82b71a91a7d72568d88115fe6b38e46b646a632bea6db92ec7cc155516
|
| 3 |
+
size 478297626
|
data/train-00057-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:25766fddb88eb7b0a954c82c2ec8b4f89ddb72bf6013994aee069f13a844f0fe
|
| 3 |
+
size 502452112
|
data/train-00058-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:214c63175e2176d566ccec58104b89dc219ab403a04fb680b60e05f0aab20e4c
|
| 3 |
+
size 438285575
|
data/train-00059-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:60db9c1e1287e7603da6b7a76c220da15118e3c28734c1a8ed46b6926e27ad7e
|
| 3 |
+
size 536844536
|
data/train-00060-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fb67fff6b980b991384d2793ba92255edd3e621629dc686586a7e5206863839c
|
| 3 |
+
size 530731306
|
data/train-00061-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dfa641bc51a6dd9b002dc6f74fcfa33fc749693b4df96f26e04c3b3a6649d509
|
| 3 |
+
size 491618239
|
data/train-00062-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3af69ed577699cf11365d66c27178296d470377d4b365b684a970ca6690e3fc3
|
| 3 |
+
size 490998036
|
data/train-00063-of-00064.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:da3831342ddc2fd8b2c503cd9dcdbd7316ce8beb3905a7e82f31518e90ab6c6a
|
| 3 |
+
size 527951222
|
early_printed_books_font_detection.py
DELETED
|
@@ -1,131 +0,0 @@
|
|
| 1 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 2 |
-
#
|
| 3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
-
# you may not use this file except in compliance with the License.
|
| 5 |
-
# You may obtain a copy of the License at
|
| 6 |
-
#
|
| 7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
-
#
|
| 9 |
-
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
-
# See the License for the specific language governing permissions and
|
| 13 |
-
# limitations under the License.
|
| 14 |
-
"""Dataset of illustrated and non illustrated 19th Century newspaper ads."""
|
| 15 |
-
|
| 16 |
-
import zipfile
|
| 17 |
-
from pathlib import Path
|
| 18 |
-
|
| 19 |
-
import datasets
|
| 20 |
-
import requests
|
| 21 |
-
from PIL import Image
|
| 22 |
-
|
| 23 |
-
# Some of the images are large so we set this to avoid Decompression bomb warnings
|
| 24 |
-
|
| 25 |
-
Image.MAX_IMAGE_PIXELS = None
|
| 26 |
-
|
| 27 |
-
_CITATION = """\
|
| 28 |
-
@dataset{seuret_mathias_2019_3366686,
|
| 29 |
-
author = {Seuret, Mathias and
|
| 30 |
-
Limbach, Saskia and
|
| 31 |
-
Weichselbaumer, Nikolaus and
|
| 32 |
-
Maier, Andreas and
|
| 33 |
-
Christlein, Vincent},
|
| 34 |
-
title = {{Dataset of Pages from Early Printed Books with
|
| 35 |
-
Multiple Font Groups}},
|
| 36 |
-
month = aug,
|
| 37 |
-
year = 2019,
|
| 38 |
-
publisher = {Zenodo},
|
| 39 |
-
version = {1.0.0},
|
| 40 |
-
doi = {10.5281/zenodo.3366686},
|
| 41 |
-
url = {https://doi.org/10.5281/zenodo.3366686}
|
| 42 |
-
}
|
| 43 |
-
"""
|
| 44 |
-
|
| 45 |
-
_DESCRIPTION = """\
|
| 46 |
-
This dataset is composed of photos of various resolution of 35'623 pages of printed books dating from the 15th to the 18th century. Each page has been attributed by experts from one to five labels corresponding to the font groups used in the text, with two extra-classes for non-textual content and fonts not present in the following list: Antiqua, Bastarda, Fraktur, Gotico Antiqua, Greek, Hebrew, Italic, Rotunda, Schwabacher, and Textura.
|
| 47 |
-
"""
|
| 48 |
-
|
| 49 |
-
_HOMEPAGE = "https://doi.org/10.5281/zenodo.3366686"
|
| 50 |
-
_LICENSE = "Creative Commons Attribution Non Commercial Share Alike 4.0 International"
|
| 51 |
-
|
| 52 |
-
ZENDO_REPO_ID = 3366686
|
| 53 |
-
ZENODO_API_URL = f"https://zenodo.org/api/records/{ZENDO_REPO_ID}"
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
class EarlyBookFonts(datasets.GeneratorBasedBuilder):
|
| 57 |
-
"""Early printed book fonts detection dataset"""
|
| 58 |
-
|
| 59 |
-
VERSION = datasets.Version("1.1.0")
|
| 60 |
-
|
| 61 |
-
def _info(self):
|
| 62 |
-
features = datasets.Features(
|
| 63 |
-
{
|
| 64 |
-
"image": datasets.Image(),
|
| 65 |
-
"labels": datasets.Sequence(
|
| 66 |
-
datasets.ClassLabel(
|
| 67 |
-
names=[
|
| 68 |
-
"greek",
|
| 69 |
-
"antiqua",
|
| 70 |
-
"other_font",
|
| 71 |
-
"not_a_font",
|
| 72 |
-
"italic",
|
| 73 |
-
"rotunda",
|
| 74 |
-
"textura",
|
| 75 |
-
"fraktur",
|
| 76 |
-
"schwabacher",
|
| 77 |
-
"hebrew",
|
| 78 |
-
"bastarda",
|
| 79 |
-
"gotico_antiqua",
|
| 80 |
-
]
|
| 81 |
-
)
|
| 82 |
-
),
|
| 83 |
-
}
|
| 84 |
-
)
|
| 85 |
-
|
| 86 |
-
return datasets.DatasetInfo(
|
| 87 |
-
description=_DESCRIPTION,
|
| 88 |
-
features=features,
|
| 89 |
-
homepage=_HOMEPAGE,
|
| 90 |
-
license=_LICENSE,
|
| 91 |
-
citation=_CITATION,
|
| 92 |
-
)
|
| 93 |
-
|
| 94 |
-
def _split_generators(self, dl_manager):
|
| 95 |
-
zenodo_record = requests.get(ZENODO_API_URL).json()
|
| 96 |
-
urls = sorted(
|
| 97 |
-
file["links"]["self"]
|
| 98 |
-
for file in zenodo_record["files"]
|
| 99 |
-
if file["type"] == "zip"
|
| 100 |
-
)
|
| 101 |
-
*image_urls, label_url = urls
|
| 102 |
-
labels = dl_manager.download(label_url)
|
| 103 |
-
images = dl_manager.download_and_extract(image_urls)
|
| 104 |
-
|
| 105 |
-
return [
|
| 106 |
-
datasets.SplitGenerator(
|
| 107 |
-
name=datasets.Split.TRAIN,
|
| 108 |
-
gen_kwargs={"images": images, "labels": labels, "split": "training"},
|
| 109 |
-
),
|
| 110 |
-
datasets.SplitGenerator(
|
| 111 |
-
name=datasets.Split.TEST,
|
| 112 |
-
gen_kwargs={"images": images, "labels": labels, "split": "test"},
|
| 113 |
-
),
|
| 114 |
-
]
|
| 115 |
-
|
| 116 |
-
def _generate_examples(self, images, labels, split):
|
| 117 |
-
mapping = {}
|
| 118 |
-
for directory in images:
|
| 119 |
-
for file in Path(directory).rglob("*"):
|
| 120 |
-
mapping["/".join(file.parts[-2:])] = file
|
| 121 |
-
with zipfile.ZipFile(labels) as labelzip:
|
| 122 |
-
with labelzip.open(f"labels-{split}.csv") as label_csv:
|
| 123 |
-
for id_, row in enumerate(label_csv.readlines()):
|
| 124 |
-
row = row.decode("utf-8")
|
| 125 |
-
filename, *labels = row.split(",")
|
| 126 |
-
labels = [label.strip("\n") for label in labels]
|
| 127 |
-
labels = [label for label in labels if label != "-"]
|
| 128 |
-
filename = mapping[filename]
|
| 129 |
-
|
| 130 |
-
image = Image.open(filename)
|
| 131 |
-
yield id_, {"image": image, "labels": labels}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|