tanganke commited on
Commit
756d43e
1 Parent(s): 9e274cb

Upload folder using huggingface_hub

Browse files
.DS_Store ADDED
Binary file (6.15 kB). View file
 
README.md ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ dataset_info:
3
+ config_name: kmnist
4
+ features:
5
+ - name: image
6
+ dtype: image
7
+ - name: label
8
+ dtype:
9
+ class_label:
10
+ names:
11
+ '0': お
12
+ '1': き
13
+ '2': す
14
+ '3': つ
15
+ '4': な
16
+ '5': は
17
+ '6': ま
18
+ '7': や
19
+ '8': れ
20
+ '9': を
21
+ splits:
22
+ - name: train
23
+ num_bytes: 27055217
24
+ num_examples: 60000
25
+ - name: test
26
+ num_bytes: 4520213
27
+ num_examples: 10000
28
+ download_size: 21240888
29
+ dataset_size: 31575430
30
+ ---
31
+
32
+ # KMNIST Dataset
33
+
34
+ lassify images from the KMNIST dataset into one of the 10 classes, representing different Japanese characters.
kmnist.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import struct
2
+
3
+ import numpy as np
4
+
5
+ import datasets
6
+ from datasets.tasks import ImageClassification
7
+
8
+ _CITATION = R"""
9
+ @article{DBLP:journals/corr/abs-1812-01718,
10
+ author = {Tarin Clanuwat and
11
+ Mikel Bober{-}Irizar and
12
+ Asanobu Kitamoto and
13
+ Alex Lamb and
14
+ Kazuaki Yamamoto and
15
+ David Ha},
16
+ title = {Deep Learning for Classical Japanese Literature},
17
+ journal = {CoRR},
18
+ volume = {abs/1812.01718},
19
+ year = {2018},
20
+ url = {http://arxiv.org/abs/1812.01718},
21
+ eprinttype = {arXiv},
22
+ eprint = {1812.01718},
23
+ timestamp = {Thu, 14 Oct 2021 09:15:14 +0200},
24
+ biburl = {https://dblp.org/rec/journals/corr/abs-1812-01718.bib},
25
+ bibsource = {dblp computer science bibliography, https://dblp.org}
26
+ }
27
+ """
28
+
29
+ _URL = "./raw/"
30
+ _URLS = {
31
+ "train_images": "train-images-idx3-ubyte.gz",
32
+ "train_labels": "train-labels-idx1-ubyte.gz",
33
+ "test_images": "t10k-images-idx3-ubyte.gz",
34
+ "test_labels": "t10k-labels-idx1-ubyte.gz",
35
+ }
36
+
37
+
38
+ class KMNIST(datasets.GeneratorBasedBuilder):
39
+
40
+ BUILDER_CONFIGS = [
41
+ datasets.BuilderConfig(
42
+ name="kmnist",
43
+ version=datasets.Version("1.0.0"),
44
+ )
45
+ ]
46
+
47
+ def _info(self):
48
+ return datasets.DatasetInfo(
49
+ features=datasets.Features(
50
+ {
51
+ "image": datasets.Image(),
52
+ "label": datasets.features.ClassLabel(
53
+ names=[
54
+ "お",
55
+ "き",
56
+ "す",
57
+ "つ",
58
+ "な",
59
+ "は",
60
+ "ま",
61
+ "や",
62
+ "れ",
63
+ "を",
64
+ ]
65
+ ),
66
+ }
67
+ ),
68
+ supervised_keys=("image", "label"),
69
+ homepage="https://github.com/rois-codh/kmnist",
70
+ citation=_CITATION,
71
+ task_templates=[
72
+ ImageClassification(
73
+ image_column="image",
74
+ label_column="label",
75
+ )
76
+ ],
77
+ )
78
+
79
+ def _split_generators(self, dl_manager):
80
+ urls_to_download = {key: _URL + fname for key, fname in _URLS.items()}
81
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
82
+ return [
83
+ datasets.SplitGenerator(
84
+ name=datasets.Split.TRAIN,
85
+ gen_kwargs={
86
+ "filepath": (
87
+ downloaded_files["train_images"],
88
+ downloaded_files["train_labels"],
89
+ ),
90
+ "split": "train",
91
+ },
92
+ ),
93
+ datasets.SplitGenerator(
94
+ name=datasets.Split.TEST,
95
+ gen_kwargs={
96
+ "filepath": (
97
+ downloaded_files["test_images"],
98
+ downloaded_files["test_labels"],
99
+ ),
100
+ "split": "test",
101
+ },
102
+ ),
103
+ ]
104
+
105
+ def _generate_examples(self, filepath, split):
106
+ """This function returns the examples in the raw form."""
107
+ # Images
108
+ with open(filepath[0], "rb") as f:
109
+ # First 16 bytes contain some metadata
110
+ _ = f.read(4)
111
+ size = struct.unpack(">I", f.read(4))[0]
112
+ _ = f.read(8)
113
+ images = np.frombuffer(f.read(), dtype=np.uint8).reshape(size, 28, 28)
114
+
115
+ # Labels
116
+ with open(filepath[1], "rb") as f:
117
+ # First 8 bytes contain some metadata
118
+ _ = f.read(8)
119
+ labels = np.frombuffer(f.read(), dtype=np.uint8)
120
+
121
+ for idx in range(size):
122
+ yield idx, {"image": images[idx], "label": str(labels[idx])}
kmnist_classmap.csv ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ index,codepoint,char
2
+ 0,U+304A,お
3
+ 1,U+304D,き
4
+ 2,U+3059,す
5
+ 3,U+3064,つ
6
+ 4,U+306A,な
7
+ 5,U+306F,は
8
+ 6,U+307E,ま
9
+ 7,U+3084,や
10
+ 8,U+308C,れ
11
+ 9,U+3092,を
raw/t10k-images-idx3-ubyte.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:edd7a857845ad6bb1d0ba43fe7e794d164fe2dce499a1694695a792adfac43c5
3
+ size 3041136
raw/t10k-labels-idx1-ubyte.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20bb9a0ef54c7db3efc55a92eef5582c109615df22683c380526788f98e42a1c
3
+ size 5120
raw/train-images-idx3-ubyte.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:51467d22d8cc72929e2a028a0428f2086b092bb31cfb79c69cc0a90ce135fde4
3
+ size 18165135
raw/train-labels-idx1-ubyte.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e38f9ebcd0f3ebcdec7fc8eabdcdaef93bb0df8ea12bee65224341c8183d8e17
3
+ size 29497