JAWCF commited on
Commit
1dd67d1
·
1 Parent(s): bc8f205

Create characters.py

Browse files
Files changed (1) hide show
  1. characters.py +71 -0
characters.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.Wikipedia
15
+
16
+ # Lint as: python3
17
+ """Dream!n character datasets"""
18
+
19
+ import datasets
20
+
21
+ _CITATION = """
22
+ """
23
+
24
+ _DESCRIPTION = "Dream!n character datasets"
25
+
26
+
27
+ _DATASET_URL = "https://huggingface.co/datasets/JAWCF/character-demo/resolve/main/images.tar.gz"
28
+
29
+
30
+ class Characters(datasets.GeneratorBasedBuilder):
31
+
32
+ def _info(self):
33
+ features = datasets.Features({
34
+ 'image': datasets.Image(),
35
+ 'text': datasets.Value('string')
36
+ })
37
+ return datasets.DatasetInfo(
38
+ # This is the description that will appear on the datasets page.
39
+ description=_DESCRIPTION,
40
+ # This defines the different columns of the dataset and their types
41
+ features=features, # Here we define them above because they are different between the two configurations
42
+ supervised_keys=None,
43
+ # Homepage of the dataset for documentation
44
+ homepage="",
45
+ # License for the dataset if available
46
+ license="",
47
+ # Citation for the dataset
48
+ citation=_CITATION,
49
+ )
50
+
51
+ def _split_generators(self, dl_manager):
52
+ path = dl_manager.download(_DATASET_URL)
53
+ image_iters = dl_manager.iter_archive(path)
54
+ splits = [
55
+ datasets.SplitGenerator(
56
+ name=datasets.Split.TRAIN,
57
+ gen_kwargs={
58
+ "images": image_iters
59
+ }
60
+ ),
61
+ ]
62
+ return splits
63
+
64
+ def _generate_examples(self, images):
65
+ """Yields examples."""
66
+ for filepath, image in images:
67
+ print(filepath)
68
+ yield {
69
+ "image": {"path": filepath, "bytes": image.read()},
70
+ "text" : "alal",
71
+ }