AlienKevin commited on
Commit
41a540e
·
1 Parent(s): b49be77

Create source_han_sans_ja_left_right

Browse files
Files changed (1) hide show
  1. source_han_sans_ja_left_right +53 -0
source_han_sans_ja_left_right ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+ _CITATION = """\
4
+ @InProceedings{huggingface:dataset,
5
+ title = {Source Han Sans JA Left-Right Characters},
6
+ author={Kevin Li},
7
+ year={2022}
8
+ }
9
+ """
10
+ _DESCRIPTION = """\
11
+ 128x128 PNG images of Left-Right Chinese Characters in Big 5 and Adobe-Japan1-7.
12
+ Font used is Source Han Sans J designed for Japanese.
13
+ """
14
+ _HOMEPAGE = "https://huggingface.co/datasets/AlienKevin/source_han_sans_ja_left_right"
15
+ _LICENSE = "CC0"
16
+ _REPO = "https://huggingface.co/datasets/AlienKevin/source_han_sans_ja_left_right"
17
+
18
+ class ImageSet(datasets.GeneratorBasedBuilder):
19
+ def _info(self):
20
+ return datasets.DatasetInfo(
21
+ description=_DESCRIPTION,
22
+ features=datasets.Features(
23
+ {
24
+ 'character': datasets.Value("string"),
25
+ 'image': datasets.Image(),
26
+ }
27
+ ),
28
+ supervised_keys=None,
29
+ homepage=_HOMEPAGE,
30
+ citation=_CITATION,
31
+ )
32
+
33
+ def _split_generators(self, dl_manager):
34
+ images_archive = dl_manager.download(f"{_REPO}/resolve/main/images.tgz")
35
+ image_iters = dl_manager.iter_archive(images_archive)
36
+ return [
37
+ datasets.SplitGenerator(
38
+ name=datasets.Split.TRAIN,
39
+ gen_kwargs={
40
+ "images": image_iters
41
+ }
42
+ ),
43
+ ]
44
+
45
+ def _generate_examples(self, images):
46
+ idx = 0
47
+ for filepath, image in images:
48
+ character = filepath.split('/')[-1][:-4]
49
+ yield idx, {
50
+ "image": {"path": filepath, "bytes": image.read()},
51
+ "character": character,
52
+ }
53
+ idx += 1